Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Increment by 2 and by 1 in same loop.

by AnomalousMonk (Canon)
on Apr 16, 2013 at 10:21 UTC ( #1028869=note: print w/replies, xml ) Need Help??


in reply to Re: Increment by 2 and by 1 in same loop.
in thread Increment by 2 and by 1 in same loop.

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); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028869]
help
Chatterbox?
[marto]: it makes things less stressful for the parents that's for sure :P
[Corion]: Yeah (although their mother was somewhat stressed out regardless) - but it made for an otherwise relaxed evening ;)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2016-12-08 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (139 votes). Check out past polls.