It's also possible to define (and initialize, if needed) two (or more) lexical loop variables entirely locally:
for (my ($i, $n) = (1, 2); $i < $limit; $i += 2, ++$n) { do_something_with($i, $n); }
In reply to Re^2: Increment by 2 and by 1 in same loop.
by AnomalousMonk
in thread Increment by 2 and by 1 in same loop.
by freekngeek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |