in reply to Re: 'local' for imported variables doesn't work as expected
in thread 'local' for imported variables doesn't work as expected
So exporting the whole typeglob will fix it.:).
In case exporter doesn't support * , use your own import
This perfectly does the job!
I replaced
byour @EXPORT = qw( %debug $d_area dsay );
in Dsay.pm.our @EXPORT = qw( %debug *d_area dsay );
I now can use
and get debugging output from the 'two' area only. Debugging output stops as soon as the localized $d_area value drops out of scope.sub one { local $d_area = "one"; dsay "debugging output from one"; } sub two { local $d_area = "two"; dsay "debugging output from two"; } $debug{TWO} = 1; one; two;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: 'local' for imported variables doesn't work as expected
by LanX (Saint) on Oct 07, 2024 at 21:28 UTC |