Re: Read file at startup, access data during request?
On Thu, 29 Mar 2001, Richard Anderson wrote: > I want to read and parse a file when Apache mod_perl starts and have access to the >data while my mod_perl methods are processing the request. The most obvious approach >(to me) is to put the reading/parsing code at the beginning of my mod_perl module, >outside of my methods, and load the data into a package array variable that my >methods can access during request processing. > > However, I want to put the pathname of the file (relative to ServerRoot) in the >httpd.conf file as a PerlSetVar. I don't see any way to access the value of a >PerlSetVar until the request phase. In other words, in the module code that runs at >startup time, I want to do this: > > my $file = $r->server_root_relative($r->dir_config('SharedSecretKeyFile')); > > except I don't have the Apache Request object ($r). > > Am I completely on the wrong track? Is there some way to access a PerlSetVar >without the request object? How about this: httpd.conf: use My::Preload; My::Preload::init('SharedSecretKeyFile'); But you can do this as well: my $s = Apache->server; my $file = $s->dir_config('SharedSecretKeyFile'); The former seems simpler to me... and it's pretty much all in the guide :) _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://logilune.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Read file at startup, access data during request?
I want to read and parse a file when Apache mod_perl starts and have access to the data while my mod_perl methods are processing the request. The most obvious approach (to me) is to put the reading/parsing code at the beginning of my mod_perl module, outside of my methods, and load the data into a package array variable that my methods can access during request processing. However, I want to put the pathname of the file (relative to ServerRoot) in the httpd.conf file as a PerlSetVar. I don't see any way to access the value of a PerlSetVar until the request phase. In other words, in the module code that runs at startup time, I want to do this: my $file = $r->server_root_relative($r->dir_config('SharedSecretKeyFile')); except I don't have the Apache Request object ($r). Am I completely on the wrong track? Is there some way to access a PerlSetVar without the request object? Richard Anderson, Ph.D. www.unixscripts.com Perl / Java / SQL / Unix [EMAIL PROTECTED] Raycosoft, LLC Seattle, WA, USA