Tom Phoenix rb-pdx-pm at
Wed Aug 15 17:18:51 CDT 2001

On Wed, 15 Aug 2001, Greg Minter wrote:

>   I don't think that variable settings can be seen across files. They
> must be read from subroutines.

Well, yes and no. If an external file (like a module or library file) has
any lexical variables (also called "my" variables), those can't be used
from outside the file. But it may use global variables (sometimes called
"package" variables) that are usable from every line of the program, even
in other files.

>From the other side of the mirror, if your main program uses "my"
variables, those can't be used from the external file. If you want them to
be initialized directly by the external file (and still be "my"
variables), you would have to pass them to a subroutine as parameters to
be modified. This isn't frequently done, though. It's more common to set
them in the main program, something like this:

    my($name, $addr, @favorite_books) = &external_initialization();

...which is what I think you were saying, when you said they "must be read
from subroutines".


Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:


More information about the Pdx-pm-list mailing list