William Bulley wrote:
...


Perhaps the reason that syntax is used may have come from this POD:

   
<http://search.cpan.org/~phred/mod_perl-2.0.5/docs/api/Apache2/Const.pod#:common>

Right, but what that page is showing, is the syntax of the perl "use some::module;" directive, as used /inside of a perl program/. Here we are talking about the "PerlModule" directive, as used in a httpd.conf file (or another file included in it).

Although the effect of each of these instructions is quite similar, the allowable syntax in each case may be different.

Referring again to the page
http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlModule_

One sees there an example of a PerlModule directive with several parameters after the "PerlModule" directive itself. But these additional parameters are, all and each of them, names of perl modules (aka "libraries") to be loaded. They are /not/ additional parameters to the first named module.
Damn, this is probably obscure for a non-perl practitioner.  Let me try again :

in a line like
use Apache2::Const -compile => ':common';
(which you would use in a perl script, not in an Apache configuration file)
- the "use Apache2::Const" part means : load the module "Apache2::Const"
- and the "-compile => ':common'" part means : /in addition/ to loading the Apache2::Const module itself, also "prepare" a set of symbols from that module, so as to make them easier to use in the program which executes the "use" directive. (*)

On the other hand, in an Apache configuration file, you cannot use the "use" directive, you must use the "PerlModule" directive. But this PerlModule directive has no valid syntax to allow the second part ("-compile => ':common'").

Ok so far ?

So how would you find a way to tell Apache and mod_perl to load the Apache2::Const module, but /also/ do the "-compile => ':common'" part ?

Fortunately, in Perl there is always more than one way to do it.
That's where the already-named "startup.pl" script comes into play, along with the "PerlRequire" directive.

By using the Apache/mod_perl configuration directive
PerlRequire "/path/to/some/script.pl"
you tell Apache and mod_perl to also compile and run the named script, /during the Apache configuration phase/. And in this script, you can use the line :
use Apache2::Const -compile => ':common';
(because in a Perl script the "use" directive /can/ be used, with the additional parameters and all).

(Note: the name of this script is often "startup.pl", but that is only a convention, and you can use any script name you like, as long as the PerlRequire directive points to it). (Note also that it does not matter that the rest of the application never references this script; it is executed /once/ during the configuration phase of Apache, and just sets things up for the rest of the life of this Apache/mod_perl server).


In other words, to summarise (and this is only a repeat of what someone else wrote earlier), do as follows :

- create a simple perl script, for example as "/etc/apache2/mod_perl_startup.pl", as Fred Moyer told you how to in a reply dated 17/06 22:22. - remove the corresponding PerlModule line from the Apache configuration file (or comment it out)
- add the above "PerlRequire" line to your Apache configuration

The fundamental effect should be the same, but the perl language "use" directive allows for additional parameters such as "-compile", while this is less than certain for the Apache/mod_perl "PerlModule" configuration directive.


(*) for example, it means that in all other perl programs, modules, scripts running under your Apache/mod_perl, you can now use :

return OK;

instead of the longer

return Apache2::Const::OK;







Reply via email to