in reply to Re: How to use variables from other package?
in thread How to use variables from other package?
The classic way to do this is to export those variables via Exporter.
Another, easier (tidier) way is to do so using Exporter::Tidy. That way, you get to export the lexical so that in your module you don't have the overhead that package global variables normally have.
And then, in the code that uses the package, unchanged:package Foo; use Exporter::Tidy _map => { '$foo' => \my $foo }; $foo = 3;
use Foo qw($foo); print $foo;
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|