in reply to my Scope Pop Quiz
This came up recently, so I know that:
1) strict doesn't complain. $rv is in a foreach loop, but it's not in a block (so it's file scoped).
2) I have no idea why, but after the loop, $rv will be set to the null string ("") and not 42 or undef. Therefore, the output will be a blank line.
my ... foreach ... is to be avoided.
Update: While I don't get any warnings under -w or use warnings, print(defined($rv)?1:0, "\n"); prints 0, indicating $rv is undefined. ActivePerl v5.6.1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: my Scope Pop Quiz
by Mr. Muskrat (Canon) on Apr 09, 2005 at 01:36 UTC | |
by ikegami (Patriarch) on Apr 09, 2005 at 05:13 UTC | |
by Tanktalus (Canon) on Apr 09, 2005 at 14:12 UTC | |
by ikegami (Patriarch) on Apr 09, 2005 at 14:26 UTC | |
|
Re^2: my Scope Pop Quiz
by Random_Walk (Prior) on Apr 09, 2005 at 16:33 UTC |