Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to take a list (@list) and split it up into an array of 38 arrays each contains 38 values from my @list, they are already in order it just has to step through and get the data. moving it from @list to my 2d array @temp as it goes here is the code for the sub i am using
use strict; use warnings; sub sortList{ my @temp ; my (@list) = @_; my $j; my $count = 0; for (my $i =0; $i< 38; $i += 1){ for ( $j=0; $j<38; $j+= 1){ push (@{$temp[$i]}, $list[$count]); $count += 1; } } return @temp; }
rather than getting the values in my my output i am getting a list of array reference numbers not sure why. This is my first time using a 2D array any wisdom would be appreciated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2D arrays
by davido (Cardinal) on Jul 02, 2012 at 20:50 UTC | |
|
Re: 2D arrays
by toolic (Bishop) on Jul 02, 2012 at 21:02 UTC | |
by Anonymous Monk on Jul 03, 2012 at 12:04 UTC | |
|
Re: 2D arrays
by AnomalousMonk (Archbishop) on Jul 02, 2012 at 23:20 UTC | |
|
Re: 2D arrays
by TJPride (Pilgrim) on Jul 03, 2012 at 02:43 UTC |