Re: mapping URI to filename.

2008-08-19 Thread Geoffrey Young


Anthony R Fletcher wrote:
 Thanks but that only works for the current request. I was looking for a
 way of translating some other URI to a pathname on the same server.

$r-lookup_uri('/some/uri')-filename()

http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_uri_

--Geoff



Re: mapping URI to filename.

2008-08-19 Thread Anthony R Fletcher
Perfect. Thank you.

Anthony

On 19 Aug 2008 at 09:53:03, Geoffrey Young wrote:
 
 
 Anthony R Fletcher wrote:
  Thanks but that only works for the current request. I was looking for a
  way of translating some other URI to a pathname on the same server.
 
 $r-lookup_uri('/some/uri')-filename()
 
 http://perl.apache.org/docs/2.0/api/Apache2/SubRequest.html#C_lookup_uri_
 
 --Geoff

-- 
Anthony R Fletcher
  Room 2033, Building 12A,http://dcb.cit.nih.gov/~arif
  National Institutes of Health,  [EMAIL PROTECTED]
  12A South Drive, Bethesda,  Phone: (+1) 301 402 1741.
  MD 20892-5624, USA.


Caching a hash - am I missing something?

2008-08-19 Thread Chris Faust
Hi,

 

This might be a little off topic, I hope it's OK to post. I'm not positive
if mod_perl matters or not because it's a little confusing to me.

 

I've taken over some pretty old code that I'm updating and making mp2
content handlers out of. The main script is a standard cgi script
start.cgi there is nothing special in the apache conf for it.

 

Directory /xxx/

SetHandler perl-script

PerlFixupHandler My::Fixup

PerlResponseHandler ModPerl::PerlRun

PerlOptions +ParseHeaders

DirectoryIndex start.cgi

Options +ExecCGI +Indexes

allow from all

/Directory

 

start.cgi calls a custom module (use CustomModule;) which exports a bunch of
subs, for example foobar and all over the place in the subs that are
exported from CustomModule I see code like

 

 

sub foobar {

my $key = @_;



if ($cache{$key}) {

return $cache{$key};

} else {

my $do_some_query = ;

$cache{$key} = $do_some_query_results

return $cache{$key};

}

}

 

My question is isn't the else in foobar always going to be true anyplace
where start.cgi is calling foobar('somekey')??

I don't understand how %cache could already be populate from a previous
browser request or something? I'm I just missing something stupid?

 

FYI this was all running before on a version of Debian with old apache and
old mod_perl (early 1.99 and 2.0.x). I've updated mod_perl to 2.0.2 and
apache to 2.2 and everything still works.

 

TIA!!

-Chris

 

 

 

 

 

 

 



Re: Caching a hash - am I missing something?

2008-08-19 Thread W. Tyler Gee
On Tue, Aug 19, 2008 at 5:35 PM, Chris Faust [EMAIL PROTECTED] wrote:
 Hi,



 This might be a little off topic, I hope it's OK to post. I'm not positive
 if mod_perl matters or not because it's a little confusing to me.



 I've taken over some pretty old code that I'm updating and making mp2
 content handlers out of. The main script is a standard cgi script
 start.cgi there is nothing special in the apache conf for it.



 Directory /xxx/

 SetHandler perl-script

 PerlFixupHandler My::Fixup

 PerlResponseHandler ModPerl::PerlRun

 PerlOptions +ParseHeaders

 DirectoryIndex start.cgi

 Options +ExecCGI +Indexes

 allow from all

 /Directory



 start.cgi calls a custom module (use CustomModule;) which exports a bunch of
 subs, for example foobar and all over the place in the subs that are
 exported from CustomModule I see code like





 sub foobar {

 my $key = @_;



 if ($cache{$key}) {

 return $cache{$key};

 } else {

 my $do_some_query = ;

 $cache{$key} = $do_some_query_results

 return $cache{$key};

 }

 }



 My question is isn't the else in foobar always going to be true anyplace
 where start.cgi is calling foobar('somekey')??

 I don't understand how %cache could already be populate from a previous
 browser request or something? I'm I just missing something stupid?

%cache is defined outside the scope of the sub so it will persist for
the lifetime of the apache server.  The very first time
foobar('somekey') is called it will do the query lookup, the next time
it will return from cache.




 FYI this was all running before on a version of Debian with old apache and
 old mod_perl (early 1.99 and 2.0.x). I've updated mod_perl to 2.0.2 and
 apache to 2.2 and everything still works.



 TIA!!

 -Chris

















-- 
~Tyler