in reply to Re: Re: Re: Never lock $0 inside of a BEGIN block
in thread Never lock $0 inside of a BEGIN block
Heh. Ive encountered a bunch of weirdness with using my and modifiers. (I've even argued that it should produce a warning.) I haven't seen the static variable trick. Thats scary. Cool Scary though. :-)
However I'm still not convinced that this error message couldn't be improved.
BTW, the static trick only works with if 0; and for (); and thus I still consider it something that should produce a warning.
sub umm() { print "---\n"} sub _caller(){(caller(1))[3]=~/^(?:main::)?(.*)$/} sub for_blah { my $foo for 1; printf "%-15s %d\n",_caller,$foo++; } sub not_for_blah { my $foo for (); printf "%-15s %d\n",_caller,$foo++; } sub if_blah { my $foo if 1; printf "%-15s %d\n",_caller,$foo++; } sub not_if_blah { my $foo if 0; printf "%-15s %d\n",_caller,$foo++; } for_blah(),for_blah(),for_blah(),umm, not_for_blah(),not_for_blah(),not_for_blah(),umm, if_blah(),if_blah(),if_blah(),umm, not_if_blah(),not_if_blah(),not_if_blah(),umm; __END__
# No assignment #With assignment for_blah 0 for_blah 0 for_blah 0 for_blah 0 for_blah 0 for_blah 0 --- --- not_for_blah 0 not_for_blah 0 not_for_blah 1 not_for_blah 1 not_for_blah 2 not_for_blah 2 --- --- if_blah 0 if_blah 1 if_blah 0 if_blah 1 if_blah 0 if_blah 1 --- --- not_if_blah 0 not_if_blah 0 not_if_blah 1 not_if_blah 1 not_if_blah 2 not_if_blah 2 --- ---
|
---|
Replies are listed 'Best First'. | |
---|---|
Static variables (oh, the horror())
by ChemBoy (Priest) on May 21, 2003 at 22:07 UTC | |
by demerphq (Chancellor) on May 22, 2003 at 08:39 UTC |