Re: Accessing main:: from within a package

[prev] [thread] [next] [Date index for 2005/05/27]

From: Perrin Harkins
Subject: Re: Accessing main:: from within a package
Date: 14:18 on 27 May 2005
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

Accessing main:: from within a package
Ken Clarke 01:30 on 27 May 2005

Re: Accessing main:: from within a package
Stas Bekman 03:21 on 27 May 2005

Re: Accessing main:: from within a package
Perrin Harkins 14:18 on 27 May 2005

Generated at 20:12 on 05 Jun 2005 by mariachi v0.52