withfor $n (1 .. 100)
as the former is an alias for foreach with the localization of the loop variable enabled (for the reasons that have been cited above), and the latter a straight loop counter similar in semantics as C's for() loop.for($n = 1; $n <= 100; ++$n)
This reminds me of being bitten by the following several years ago:
A C programmer would think nothing of this loop. It's a straight do/while loop with a break (or its perl equivalent) statement, right?do { ..... last if $some_condition; } while($some_other_condition);
Wrong. last/next doesn't work in this situation, because it isn't really a do/while loop, but rather a do BLOCK with a post condition (the while($some_other_condition) could just as well have been an unless() or if()).
Michael
In reply to Re: for loop localisation bug?
by mpeppler
in thread for loop localisation bug?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |