With List::MoreUtils:
use strict; use warnings; use Test::More tests => 2; use List::MoreUtils 'part'; my ($C, $R) = (4, 3); my @list = 1..12; my $i = 0; my @AoA = part { int ($i++ / $C) } @list; is_deeply \@AoA, [[1 .. 4], [5 .. 8], [9 .. 12]]; is_deeply \@list, [1..12];
🦛
In reply to Re: List into two-dimensional array
by hippo
in thread List into two-dimensional array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |