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