in reply to Re: A curious case of of my()
in thread A curious case of of my()
Anyway I'm wondering why a post-fix if doesn't force a new scope, IMHO that would solve the problem in a consistent way:
use strict; use warnings; $a=0; if ($a) { my $z=666; } my $y=666 if $a; print $y; # -> nothing print $z; # -> Global symbol "$z" requires explicit package na +me
of course treating short circuit and in the same way could cause more complications.
$a and my $x =666; print $x; # -> nothing
At least this "it's a new scope" logic could be used to detect "my"-problems at compile-time and throw warnings.
Cheers Rolf
UPDATE: short-circuit and
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A curious case of of my()
by ikegami (Patriarch) on Apr 05, 2011 at 16:13 UTC | |
by LanX (Saint) on Apr 05, 2011 at 16:18 UTC | |
by ikegami (Patriarch) on Apr 05, 2011 at 18:11 UTC |