in reply to Transpose a bi-dimensional array


Here is one way:
#!/usr/bin/perl -wl use strict; use Data::Dumper; my @matrix = ( [ qw(ab cd ef gh)], [ qw(ij kl mn op)], [ qw(qr st uv wx)] ); my @transpose; for my $aref (@matrix) { my $i = 0; push @{$transpose[$i++]}, $_ for @$aref; } print Dumper(@matrix); print Dumper(@transpose); __END__

--
John.

Replies are listed 'Best First'.
Re^2: Transpose a bi-dimensional array
by Anonymous Monk on Apr 02, 2016 at 19:21 UTC
    Hi John, How to print the data to the specific file instead of in terminal? Thanks Anil