in reply to perl v5.16 bug?
The problem is that the entire while condition is evaluated every time around the loop, meaning that [@a] is evaluated every time around the loop, yielding a reference to a different anonymous array every time around the loop.
Because you're polling a fresh new array every time around the loop, each's "pointer" for the array is at the beginning every time.
This is the safe way to do it:
while (my ($i, $v) = each \@a) { say "$i: $v"; }
... because you're using a reference to the same array every time around the loop.
|
|---|