On Thu, 2005-05-26 at 18:30 -0700, Ken Clarke wrote: > I have a library of perl modules which occasionally make reference to > package main:: (EG $main::ScriptGlobalHash{'hashkey'} or my $result = > &main::SomeSubroutine(\%args)) However, if my understanding of the docs is > correct, my "main" script now belongs to a request URL specific package > namespace. How should I properly (read safely/portably) refer to my "main" > package? Put another way, how should my packages refer to variables, > subroutines, handles etc which belong to the "top level script".
Ideally you wouldn't do it that way. If you have modules that need values from the calling script, you should either pass them to the subs you call, create a module with subs that you can use to access them, or export them from a module which the different parts of your script can share. The last is closest to what you're doing now. Take a look at the examples of sharing config data here: http://perl.apache.org/docs/1.0/guide/porting.html#Configuration_Files__Writing__Dynamically_Updating_and_Reloading - Perrin