use Text::CSV; use Math::MatrixReal; my $mref = [ [ 'a', 'b', 'c', 'd', 'e' ], ]; my $matrix = Math::MatrixReal->new_from_rows( $mref ); print $matrix; # this will print [ 'a', 'b', 'c', 'd', 'e' ] # I want to reverse the order inside the matrix which I need later on to do some more operations. Appreciate the help. $matrix->swap_col(1,5); $matrix->swap_col(2,4); #Result: I want the result to be printed like below # print $matrix = [ 'e', 'd', 'c', 'b', 'a' ]