On Sun, 10 Sep 2000, Neil Conway wrote:
> However, I'd rather not parse the entire config file for every single
> request (the config file may be very long, and/or consist of multiple
> files). Is there any way to parse the config file once, store the
> results, and make the data available to any of my code?

Yes, if you load things up in startup (before the fork) they will be
available to all processes for reading.  See
http://thingy.kcilink.com/modperlguide/perl/Using_Global_Variables_and_Shari.html

> I was thinking of putting the parsing code into a Perl module, and `use`ing
> the module in startup.pl . But will this ensure that the file is only
> parsed once?

Yes.  See the perl man pages or
http://thingy.kcilink.com/modperlguide/perl/use_require_do_INC_and.html

> When subsequent scripts 'use' the module, won't this require
> parsing the file again?

> One more thing - it would be nice to be able to re-parse the config file
> when someone sends Apache a certain signal. Is this possible?

Yes.  If you delete a module from %INC, you can require it again.  Of
course you'll lose the shared memory savings, because each child will have
it's own copy now.

- Perrin

Reply via email to