Re: mod_perl [was: Newbie...]

2003-02-06 11:59:10
On February 6, 2003 at 16:02, Gunnar Hjalmarsson wrote:

A couple of years ago, I struggled with making a program mod_perl ready, 
and I got some advise from a programmer who sets up mod_perl 
installations professionally.

As regards the name space 'main', he emphasized that I couldn't use any 
global variables in main, while 'my' variables in main was okay.

Earl Hood wrote:
You may want to add a package statement at the beginning of
to make sure it runs in a different namespace than main.

Since there are no global variables in, I don't think it's 
necessary (see above). Nevertheless, it can't hurt...

I always make it practice for any non-trivial script to qualify
it in its own namespace, mainly to protect the code from any
other misbehaving modules or libraries it may use.

Also, things like bare filehandles (e.g. open(LOG, ...)) are
affected by the namespace.  In your current code, the LOG is in
the main:: namespace (as part of *LOG).

Since would stay loaded,

Would it? I thought it would be the modules that stayed loaded. 'My 
advisor' prompted me to move as much as possible from CGI files to 
module files for that reason.

Assume your script stays loaded and is just reinterpreted.  For
example, BEGIN blocks are only executed once, but the other code
can be executed multiple times.

The only time your script is "unloaded" is if the Apache child process
is reaped by the main process (which happens periodically).

MHonArc is coded to supported embedded usage (via
and have the ability to processing multiple archives (sequently)
in a single process, so I believe MHonArc should be okay.

One thing strucks me: The MHonArc modules are Perl4 style. Would they 
still be kept loaded under mod_perl?

The term "module" and "library" are arbitrary constructs.  To Perl, it
is all source, and it is the `package' statement that really provides
the modularization piece of Perl.  Any file that is parsed by the
interpreter, the parsed tree will be persistent for some period of
time within mod_perl.

Only files that are loaded during server startup -- there are mod_perl
configuration directives to pre-load files -- will stay persistent
through out the life of the Apache main process.  All others vary
depending on the life-span of the child processes.

Shouldn't we better advise Bill to stick with CGI for the time being?

Agreed, but if he is willing to try it, let him go for it.  IMO,
mod_perl execution provides little, to no, benefits since
is only invoked occassionaly, so real-time performance is not
a concern.  Plus, most of the processing overhead will be in
POP mail retrieval and/or MHonArc archive processing.  The CGI overhead
is probably negligable in this context.


To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the

<Prev in Thread] Current Thread [Next in Thread>