I ran a quick test on my mobile, and this works for me.
Probably an issue with Exporter ?
use v5.12; use warnings; BEGIN{ package log; our $var= "default"; sub tst { say $var } # export *::var = *var; *::tst = *tst; } package main; our $var; { local $var = "foo"; tst(); } tst();
perl local_import_var.pl foo default
Anyway I'd rather recommend another design, like using caller to get the function's name or setting a regex to parse the message for keywords.
HTH :)
AHH, got it. What exporter does is to only export the scalar slot, which is causing your problem.
*::var = \$var; # replace!
Effect:
perl local_import_var.pl default default
So exporting the whole typeglob will fix it.:).
In case exporter doesn't support * , use your own import
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
by LanX
in thread 'local' for imported variables doesn't work as expected
by muthm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |