#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 reply to Re: Variable scope in while loop
by frozenwithjoy
in thread Variable scope in while loop
by euswdwj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |