Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: 'local' for imported variables doesn't work as expected

by muthm (Sexton)
on Oct 06, 2024 at 22:28 UTC ( [id://11162073]=note: print w/replies, xml ) Need Help??


in reply to Re: 'local' for imported variables doesn't work as expected
in thread 'local' for imported variables doesn't work as expected

LanX wrote:
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

our @EXPORT = qw( %debug $d_area dsay );
by
our @EXPORT = qw( %debug *d_area dsay );
in Dsay.pm.

I now can use

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;
and get debugging output from the 'two' area only. Debugging output stops as soon as the localized $d_area value drops out of scope.
And this without the need of qualifying $Dsay::d_area anymore!

Thank you so much! This really helps, and I have learned a lot!

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
    > Thank you so much!

    You're very welcome! :)

    > This really helps, and I have learned a lot!

    Great. It's nice to hear that once in a while ... :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11162073]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-11-13 00:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    chatterbot is...






    Results (39 votes). Check out past polls.