Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Variable scope in while loop

by tobyink (Abbot)
on Dec 19, 2012 at 22:19 UTC ( #1009650=note: print w/ replies, xml ) Need Help??


in reply to Variable scope in while loop

Basically, each time you say my $variable you get a brand, spanking new variable. So you're reading a number into the $number variable, but then you say my $number and get a brand, spanking new variable, which happens to have undef as it's value.

my $number; $number = 40; my $number; if ($number > 39) { print "bigger than 39\n"; } elsif ($number < 1) { print "smaller than 1\n"; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-30 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls