perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Lembark <>
Subject Re: Are global variables truly global?
Date Sun, 04 Nov 2001 19:33:05 GMT

-- "Chui G. Tey" <>

> I have some state data that I need to persist between requests. At the
> moment these are COM objects, but they'll be ported to Perl Classes. It
> is quite important that only one of these instances exist per web
> server. These instances are too large to write and read to file on every
> request. So I have defined the variable as a package level variable.
> I have been instantiating the variable in my handler() routine if it has
> not already been instantiated. ie.

Global variables are exactly that: global. If you use
something like:

    our $foo ||= somefunc;


    our $foo = Someclass->constructor( @blah );

then you'll get a value that goes into the symbol table and
is unique w/in the executing process. Thing you'll need to
read up on are global variables, packages/namespaces and
how "use strict" effects things (all of which are in the Camel
or Llama books).

Steven Lembark                               2930 W. Palmer
Workhorse Computing                       Chicago, IL 60647
                                            +1 800 762 1582

View raw message