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\"; }
my $i; for ( qw(a b c d) ) { if (!defined($i)) { $i = $_; next; } print STDOUT "i = $i, j = $_\n"; undef($i); }
Outputs:
i = a, j = b i = c, j = d
It also works for lists, not only for arrays.