my @a = qw(a b c d e f g); my $n = 3; my @b; for (0 .. $#a/$n) { push @b, [ @a[$_*$n .. $_*$n+$n-1] ]; }