What I\'m looking for is something like:
@list = qw(1 2 3 4 5 6); foreach (@list) { #perl magic goes here print \"i: $i, j:$j\\n\"; }
here's an implementation of natatime that doesn't make a copy of the list:
sub natatime { my $n = shift; my $list = \@_; sub { return splice @$list, 0, $n; } } my $it = natatime(3, qw(1 2 3 4 5 6)); while ( my @list = $it->() ) { print "@list\n"; }