in reply to Iteration order of a foreach
Perldoc perlsyn says
The "foreach" keyword is actually a synonym for the "for" keyword, so you can use "foreach" for readability or "for" for brevity. (Or because the Bourne shell is more familiar to you than csh, so writing "for" comes more naturally.) If VAR is omitted, $_ is set to each value.As the for statement of the shells iterate over a list of words in order, I guess this guarantees the same for perl because it wants to be compatible. (Otoh awk has a for statement that iterates over an array in an undefined order, and perl is also awk-compatible, so you can't be sure.)
|
|---|