Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: How to use variables from other package?

by Juerd (Abbot)
on Apr 28, 2003 at 06:44 UTC ( [id://253607]=note: print w/replies, xml ) Need Help??


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.

package Foo; use Exporter::Tidy _map => { '$foo' => \my $foo }; $foo = 3;
And then, in the code that uses the package, unchanged:
use Foo qw($foo); print $foo;

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-01-18 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (56 votes). Check out past polls.