in reply to Re^2: Creating two dimensional array
in thread Creating two dimensional array
Most of us have interpreted the goal like this
Yes, I noticed. It would have been silly to post something that was already posted.
There's no rule that says that the first dimension must be rows and the second must be columns. Here code that shows my solution does indeed use @array1 as the first column and @array2 as the second column.
my @array1 = qw( a b c ); my @array2 = qw( X Y Z ); my @matrix = (\@array1, \@array2); for my $row (0..$#{$matrix[0]}) { for my $col (0..$#matrix) { print $matrix[$col][$row], "\t"; } print "\n"; }
a X b Y c Z
Update: Added code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Creating two dimensional array
by doom (Deacon) on Oct 31, 2007 at 08:34 UTC |