Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my ($C,$R)=(4,3); #Columns,Rows my @list = qw(1 2 3 4 5 6 7 8 9 10 11 12); my @AoA=(); while (@list) { push(@AoA, [ splice(@list, 0, $C) ]); } pp \@AoA; pp \@list; [[1 .. 4], [5 .. 8], [9 .. 12]] []
I'm seeking an equivalent without splice - so that @list remains unaffected. Any suggestions...?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: List into two-dimensional array
by hippo (Archbishop) on Dec 14, 2020 at 19:02 UTC | |
by eyepopslikeamosquito (Archbishop) on Dec 14, 2020 at 20:12 UTC | |
by Anonymous Monk on Dec 15, 2020 at 02:08 UTC | |
|
Re: List into two-dimensional array
by choroba (Cardinal) on Dec 14, 2020 at 19:14 UTC | |
|
Re: List into two-dimensional array
by Cristoforo (Curate) on Dec 14, 2020 at 20:11 UTC | |
|
Re: List into two-dimensional array
by haukex (Archbishop) on Dec 14, 2020 at 18:25 UTC | |
|
Re: List into two-dimensional array
by tybalt89 (Monsignor) on Dec 14, 2020 at 22:23 UTC | |
|
Re: List into two-dimensional array
by ikegami (Patriarch) on Dec 14, 2020 at 18:43 UTC | |
by haukex (Archbishop) on Dec 14, 2020 at 19:13 UTC | |
|
Re: List into two-dimensional array
by LanX (Saint) on Dec 14, 2020 at 21:15 UTC | |
by LanX (Saint) on Dec 14, 2020 at 21:42 UTC | |
|
Re: List into two-dimensional array
by johngg (Canon) on Dec 15, 2020 at 11:18 UTC | |
|
Re: List into two-dimensional array
by kcott (Archbishop) on Dec 16, 2020 at 22:37 UTC |