perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Doe <security.departm...@tele2.ch>
Subject Re: mod_perl: How pass variables (objects) from page to page?
Date Tue, 15 Nov 2005 09:33:03 GMT
Jeremy Nixon am Dienstag, 15. November 2005 08.06:
> Peter1 Alvin  <temp1@awebabove.com> 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

Mime
View raw message