|
|
| We don't bite newbies here... much | |
| PerlMonks |
Re: Variable scope in while loopby frozenwithjoy (Deacon) |
| on Dec 19, 2012 at 22:18 UTC ( #1009648=note: print w/ replies, xml ) | Need Help?? |
|
#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.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||