Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 56520 invoked from network); 15 Nov 2005 09:32:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 Nov 2005 09:32:09 -0000 Received: (qmail 42023 invoked by uid 500); 15 Nov 2005 09:31:59 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 41817 invoked by uid 500); 15 Nov 2005 09:31:58 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 41804 invoked by uid 99); 15 Nov 2005 09:31:58 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2005 01:31:58 -0800 X-ASF-Spam-Status: No, hits=1.4 required=10.0 tests=DNS_FROM_RFC_POST X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.247.154.200] (HELO swip.net) (212.247.154.200) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Nov 2005 01:31:49 -0800 X-T2-Posting-ID: ZAFKMsbjaVARB2dprKft3w== Received: from [212.152.11.17] (HELO the.domainname.doesntmatter.tv) by mailfe07.swip.net (CommuniGate Pro SMTP 5.0.1) with ESMTP id 10845437 for modperl@perl.apache.org; Tue, 15 Nov 2005 10:31:33 +0100 From: John Doe To: modperl@perl.apache.org Subject: Re: mod_perl: How pass variables (objects) from page to page? Date: Tue, 15 Nov 2005 10:33:03 +0100 User-Agent: KMail/1.8.1 References: <2005111419115.287860@kindness> In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200511151033.03281.security.department@tele2.ch> Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Jeremy Nixon am Dienstag, 15. November 2005 08.06: > Peter1 Alvin wrote: > > Please tell me I can do this! > > > > Using mod_perl, how do you keep Perl objects in RAM from page to page? [...] > As an example, I have a handler that needs to read a directory listing. > Most of the time it will be looking at the same directory over and over, > so I decide that it's okay to have to restart the server if the listing > will change (the listing won't change much) and do something like: > > { # start a lexical scope > my %d_cache; > sub handler { > # stuff > if (not defined($d_cache{$foo})) { > # pull in directory listing and store it in $d_cache{$foo} > } > # proceed to use $d_cache{$foo} information > } > } end lexical scope > > This way, a directory is only actually read once (at most) per server > child process. Hi Jeremy Hope it's not a stupid question, but are you sure %d_cache survives a request? Maybe I'm totally misunderstanding something but I thought after the point } end lexical scope %d_cache gets destroyed (if not still referenced from somewhere else). I would have left out the scope-{} to keep %d_cache at file level. Would that be wrong? And why? I'd appreciate every hint. joe