perlquestion
lindex
Ok so the situation is this:<br><br>
<p>
I have a simple perl script that does processes on files and is run from cron, this script reads a configuration file passed to it from command line.
</p>
<code>
#!/usr/bin/perl -w
use strict;
use vars qw($file);
$file = $ARGV[0];
open(CONF,$file) || die("$!: $file");
while(<CONF>) {
... code for parsing and storing config ...
}
close(CONF);
... more code for doing other stuff ...
</code>
<p>
I have yet another perl program, however it is not a script
it is a package used as a handler for a mod_perl enabled apache web server with an apache configuration directive such as this ...
</p>
<code>
PerlModule My::Package::Foo;
<Location /foohandler>
SetHandler perl-script
PerlHandler My::Package::Foo;
PerlSetVar FooConfig /some/patch/config.cfg
</Location>
</code>
<p>
Now as you can see there is a PerlSetVar that is the path
of a config file, this would be the same config file that the perl script running from cron uses. It is very important that these they read the same config.
</p><p>
So its simple enough for me to use the same config file
parser in the handler as I am inside of the perl script running from cron.
</p>
<CODE>
package My::Package::Foo;
sub handler {
my($r) = shift;
my($file) = $r->dir_config('FooConfig');
open(CONF,$file) || die("$!: $file");
while(<CONF>) {
... same code for parsing stuff as before ...
}
close(CONF);
... more code for doing other stuff ...
}
</code>
<p>
Ah! but it would much faster if I cached the data in the config file inside of apache, instead of re-reading/parsing
that config file for every request.
</p><p>
So question one is... what is the best method of caching data inside of apache like so?
</p><p>
And question two is... if I define another location directive that has the same handler would these two handler's share that cached data or would they be in seperate memory space inside of apache, and if they are in the same space whats the best way to seperate them?
</p><p>
ever delusional<br>
<dd>-lindex<br>
I know I should rtfm :)
</p>
<br><br><br><center>
<a href="/index.pl?node=lindex&lastnode_id=1072">lindex</a>
<CODE>
/****************************/
jason@gost.net, wh@ckz.org
http://jason.gost.net
/*****************************/
</CODE>
</center>