A for loop and a foreach loop are slightly different.
No, they are synonyms, and therefore identical.
Adding to the confusion is that for and foreach are synonyms for each other
Yes, they are synonyms, and therefore identical.
for and foreach are synonyms. They are therefore identical. However they are used (interchangeably) to introduce two completely different types of loop, the "C-style for loop":
and another one for which I know no convenient name (the "list-style for loop"?):LABEL for (EXPR; EXPR; EXPR) BLOCK
LABEL for VAR (LIST) BLOCK
It is unfortunate that the presentation of these two loop styles in perlsyn implies that the keyword for the first is "for" and for the second is "foreach", since that isn't true: the two are synonyms, hence interchangeable.
Hope this helps. :)
(no pun intended).
None implied.
Hugo
In reply to Re^4: Closures & aliases
by hv
in thread Closures & aliases
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |