Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Variable scope in while loop

by frozenwithjoy (Priest)
on Dec 19, 2012 at 22:18 UTC ( #1009648=note: print w/replies, xml ) Need Help??


in reply to Variable scope in while loop

#1 is eternal because the my re-declares $number each time such that it gets reset to undef.

#2 won't compile because you are using strict w/o declaring $number w/ my.

#3 works because you put my $number outside the loop so that when the loop loops, $number contains the value you assigned to it instead of getting reset.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009648]
help
Chatterbox?
[choroba]: Yes, "tynovsky" there is my friend and ex-colleague, I needed to beat him at Fibonacci :-)

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-10-20 09:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?