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 22, 2016 at 19: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