Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Sharing Namespaces

by Anonymous Monk
on Jan 27, 2006 at 19:50 UTC ( [id://526068]=note: print w/replies, xml ) Need Help??


in reply to Sharing Namespaces

perl -le 'BEGIN { $Foo::bar = "Hello"; %Baz:: = %Foo::; } print $Baz:: +bar'
The namespace copy has to happen at compile-time. Perl won't respect runtime namespace replacement, since it optimizes away global variable lookups into static addressing at runtime....

Replies are listed 'Best First'.
Re^2: Sharing Namespaces
by shotgunefx (Parson) on Jan 30, 2006 at 14:41 UTC
    perl -le '$Foo::bar = "Hello"; *Baz::bar = *Foo::bar; print $Baz::bar +'
    Works if you iterate over the namespace instead of trying to do it in one shot.

    For slinging around globs, you might find this snippet illustrative. Basically a very small exporter.

    Why not just use set up the module to by default, export everything you're interested in. Then it's a matter of just adding the "use" statement to each module/script, (but they're already using it right?).


    -Lee

    perl digital dash (in progress)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found