in reply to Re: Variable access across packages?
in thread Variable access across packages?

Thanks, moritz, for the reply...
But I'm looking for something different.
In your example, main is a package and access a variable declared in package B.
In my problem, main is not a package but a script and it *uses* B. And I want B to access a variable declared in main without passing it as a argument in a subroutine call.

Replies are listed 'Best First'.
Re^3: Variable access across packages?
by moritz (Cardinal) on Nov 14, 2007 at 14:24 UTC
    every script implicitly runs in the namespace main, so you can just revert the logic and access $main::VariableName if you declared it with our.

    See perlmod for details.

Re^3: Variable access across packages?
by tinita (Parson) on Nov 15, 2007 at 12:40 UTC
    And I want B to access a variable declared in main
    while this is possible (with global variables) it's generally not a good idea. why give up the modularity gained from using a module if there are other ways to solve it?