my @foo = (1..50); my @chunk; while (@chunk = splice(@foo, 0, 20)) { print "@chunk\n"; }