http://www.perlmonks.org?node_id=42647

joecamel has asked for the wisdom of the Perl Monks concerning the following question:

I am running mod_perl for Apache and I have always accessed vars from other modules using the following notation:

my $localVar = $OUTER::INNER::variable;

However, on my present project, this returns an undefined value about 30% of the time. Each time I hit refresh, it's a gamble. It fails most often after restarting the server and killing all httpd processes.

I've also tried simply "use"ing the module and accessing the vars without specifying the full package name, yielding the same results.

Does anyone know if this is a mod_perl issue and if there is a more fail-safe way of accessing package vars?

Thanks! :)

joecamel

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: Is there a fail-safe way to import variables from other modules?
by rpc (Monk) on Nov 25, 2000 at 03:06 UTC
    This isn't an issue with accessing vars from other namespaces. What you're describing is mod_perl's script caching. When you reload your browser, there is a possibility that your request gets forwarded to one of many child httpd processes. Each process possibly (and probably) has the script cached into memory.
    Try using Apache::Reload in your script.

    --rpc
Re: Is there a fail-safe way to import variables from other modules?
by merlyn (Sage) on Nov 21, 2000 at 08:19 UTC
    Sounds like a use isn't happening early enough. Can't tell more without looking at your code.