in reply to Re: Iteration order of a foreach
in thread Iteration order of a foreach
The thing is, I think for (@array) is optimized to take a reference to the array rather putting it in list context (similarly to how for (x..y) is optimized not to flatten the list).
sub f4 { for (@_) { print($_); shift; } print("\n"); } sub f5 { for ((), @_) { print($_); shift; } print("\n"); } f4(map/./g, Japh); # Jp f5(map/./g, Japh); # Japh
(Copied from Re^3: For vs. While)
I believe there are 5 kinds of for loops.
|
|---|