Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Conditional loading of module with global exports

by Tanktalus (Canon)
on Feb 22, 2016 at 22:36 UTC ( [id://1155862]=note: print w/replies, xml ) Need Help??


in reply to Conditional loading of module with global exports

Since IPC::Lite is just pushing the variable into your namespace as a global variable, I'd think a fully-scoped name would eliminate the error:

use IPC::Lite (); # always load it, why not? if ($saving) { IPC::Lite->import( Key => $0, qw(@urls) ); } push @::urls, '...';
Of course, if your namespace isn't main, then substitute appropriately, e.g., @LearnedByError::urls. Or just turn off the warning for undeclared variables around the code that uses @urls - to some people this is the "right" solution, though I'd prefer avoiding it where possible.

Though, to be honest, I'm surprised our @urls before the IPC::Lite->import... doesn't work.

Replies are listed 'Best First'.
Re^2: Conditional loading of module with global exports
by learnedbyerror (Monk) on Feb 23, 2016 at 00:20 UTC

    Tanktalus, thank you for your post. Yours was the post that made my synapses start firing to make me realize that I was living up to my erstwhile name - learnedbyerror

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 04:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found