my $i = 0; while ( $i <= $#a ) { push @b, [ @a[ $i .. $i+$n-1 ] ]; } continue { $i += $n; }