in reply to Global vars?
Issues of whether using global vars in subroutines is a good idea aside, you could look at do EXPR;. As in
do 'common.pl';
If the file common.pl contains just subroutines, these will be parsed and become a part of the calling script and will have the same scope as if they were copied into the script at the same place. Do EXPR; also uses %INC to find the file just like require.
P:\test>echo sub t{ print $global; } >test.pl P:\test>perl -e" do 'test.pl'; $global = 'Hello world!'; t();" Hello world!
Kind of the perl equivalent of C's #include, with all the caveats that entails. I'm not necessarily recommending it, but if your going to go that way anyway, perl will let you.
|
|---|