I do know that for and foreach are synonymous words. I was trying to clarify that in$_ is an implicit alias for the current @array element. While infor (@array) {$_++}$_ an alias for the current index.for (0 .. $#array) {$array[$_]++}
In your second example there, perl has no idea that $_ is an alias for the "current index." All it knows is that it is an alias for the current list element. The difference between the two examples is only in the contents of the list that the for statement is iterating over.
-sauoq "My two cents aren't worth a dime.";
In reply to Re^7: grep, map vs. foreach performance
by sauoq
in thread grep, map vs. foreach performance
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |