Return-Path: Delivered-To: apmail-modperl-archive@apache.org Received: (qmail 55870 invoked by uid 500); 5 Nov 2001 01:36:09 -0000 Mailing-List: contact modperl-help@apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Delivered-To: mailing list modperl@apache.org Received: (qmail 55859 invoked from network); 5 Nov 2001 01:36:09 -0000 Date: Sun, 04 Nov 2001 13:33:05 -0600 From: Steven Lembark Reply-To: lembark@wrkhors.com To: modperl@apache.org Subject: Re: Are global variables truly global? Message-ID: <114700000.1004902385@dizzy> In-Reply-To: <9DB60AFDAB1A5E4093762030DBB38978103ED2@WEBSERVER.advdata.com.au> References: <9DB60AFDAB1A5E4093762030DBB38978103ED2@WEBSERVER.advdata.com.au > X-Mailer: Mulberry/2.1.1 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N -- "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; or 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