package Foo; our $level = 1; sub level :lvalue {$Foo::level} package main; print $Foo::level; { local $Foo::level; # scalar localized... Foo->level = 2; # ...works on localized scalar print $Foo::level; } print $Foo::level; __END__ 121
I read local Foo->level = 2 as trying to localize an expression (the lvalue sub itself?), and not the package global this sub operates on.
A quick look with Scalar::Util::refaddr tells me after the local() call I am indeed dealing with the same address still.Hmm? $Foo::level is no reference - calling Scalar::Util::refaddr on it yields undef.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: Localize lvalue subroutine.
by shmem
in thread Localize lvalue subroutine.
by shanna
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |