instead of exporting the variable you can just check it directly in the caller's namespace. (If it even exists )
use v5.12; use warnings; BEGIN{ package log; our $var= "default"; sub tst { my $pkg= (caller)[0]; no strict 'refs'; say ${"${pkg}::var"} } # export *Other::tst = \&tst; } package Other; our $var = __PACKAGE__; { local $var = "foo"; tst(); } tst();
This might give your debugging interesting options...foo Other
An alternative to messing with strict refs is to explicitly dig thru the stashes...
say ${$::{"${pkg}::"}{"var"}};
... Tho beauty is in the eye of the beholder ;)
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
In reply to Re: 'local' for imported variables doesn't work as expected (updates 1)
by LanX
in thread 'local' for imported variables doesn't work as expected
by muthm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |