in reply to Export global variables not working correctly

I afraid the best you can do is use Alias. However for object instances you'll have to use a reference to the other object, you should think in these terms and not try to use Packages as Namespaces.
  • Comment on Re: Export global variables not working correctly

Replies are listed 'Best First'.
Re^2: Export global variables not working correctly
by davido (Cardinal) on Mar 06, 2015 at 06:53 UTC

    What's this about not trying to use packages as namespaces? The last time I looked at perlmod, I read this:

    Perl provides a mechanism for alternative namespaces to protect packages from stomping on each other's variables. In fact, there's really no such thing as a global variable in Perl. The package statement declares the compilation unit as being in the given namespace.

    And perlobj says:

    A package is simply a namespace containing variables and subroutines.


    Dave

      This thinking only works if you can stop any one from using bless and your package. Afterwards your namespace is no longer just a namespace.
        This thinking only works if you can stop any one from using bless and your package. Afterwards your namespace is no longer just a namespace.

        I've tried to wrap my head around what you are saying and am not getting anything. Would you mind showing a quick code example of the situation you are talking about?

Re^2: Export global variables not working correctly
by Anonymous Monk on Mar 06, 2015 at 06:53 UTC