Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Incrementing the loop again.

by Laurent_R (Canon)
on Mar 12, 2016 at 20:10 UTC ( [id://1157564]=note: print w/replies, xml ) Need Help??


in reply to Incrementing the loop again.

I do not see the point of modifying $i when you reach the end of the loop (and it is a bit awkward and confusing), but if you do it, it works:
$ perl -e 'my $v = 1; > for ($i = 0; $i <=100; $i++) { > $i = 2* $i if defined $v and $i == 100; > } > print $i;' 201
So, I would assume that, probably, $v is not defined in your case.

Having said that, you probably don't really want to use a C-style for loop for that, but rather a while loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1157564]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found