[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: The mod_perl book's startup.pl
From:       Rauznitz Balazs <jomagam () yahoo ! com>
Date:       1999-05-31 23:18:19
[Download RAW message or body]


--- Gerd Kortemeyer <korte@lite.msu.edu> wrote:
>
> I guess I am not really understanding the startup.pl of the "Writing
> Apache
> Modules" book (a little Perl script that is executed via PerlRequire
> from the
> Apache config files). Seems like even though I have a "use" statement
> for a
> library in that file, I need to "use" the same libraries again in my
> modules.
> What happens at those subsequent "use" statements?

Nothing happens when you "use" the same module in a Registry that you
already preloaded in startup.pl. In fact I got into the habbit of not
writing "use Module" in the script to make sure that every module used
by the script is already preloaded at server startup. (Though this
makes running those scripts from commandline really dirty.) Generally
speaking if a package is once "use"-ed, then "use"-ing it afterwards
has no effect.
 
> In particular, I would like to write a library with functions for
> TCP-connections in a network of servers, and put the "use" for it
> into startup.pl. 

Go ahead. Though I'd first check not to reinvent the wheel ;)

> At Apache startup or restart time, I would like to execute a piece of
> code that reads a configuration file - that should happen exactly
once 
> (would it happen again at every "use" in every module that "use"s?). 

Put it in startup.pl; it'll be executed once the server is (re)started.
All apache children share that copy of the package, so it'll be
consistent. All other you wrote is pure funcionalty; you use the same
caching mechanism as Apache::DBI or mod_perl itself use.

Balazs

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic