Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Variable scope in while loop

by frozenwithjoy (Curate)
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.

Comment on Re: Variable scope in while loop
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2015-11-28 20:54 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (744 votes), past polls