in reply to Array Issues
It might be nicer later on to have an array of arrays, to do this, simply use:
To access element 17, you'd use $arrays[1]->[2]my @arrays; $arrays[0] = [@array[0..14]]; $arrays[1] = [@array[15..29]]; ...
You might want to look at the Array::Dissect module which will do this for you.
Of course, it's easy to do it yourself, see the code below.
Hope this helps, -gjb-
#!/usr/bin/perl use strict; use warnings; my @aIn = (1..10); my @aOut; my $size = 3; my $counter = 0; for (@aIn) { $aOut[int($counter/$size)]->[$counter % $size] = $_; $counter++; } for my $rowIndex (0..$#aOut) { for my $columnIndex (0..$#{$aOut[$rowIndex]}) { print " $aOut[$rowIndex]->[$columnIndex]" } print "\n"; }
|
|---|