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)