question on startup.pl overriding perl search path
am 18.01.2008 08:00:05 von c chan
I use "PerlConfigRequire /var/www/html/mypath/startup.pl" in httpd.conf to recompile all the CGIs. Inside startup.pl, I added the line:
use lib qw(. mylib);
To me amazement, after all the CGI is precompiled, they start to look into the "." and "mylib" path for loading Perl Modules without even having the line [use lib qw(. mylib);] incorporated in each individual cgi script.
Can someone explain to me why this is the case? Is the mod_perl startup.pl script simply becomes the parent apache process for all the preloaded CGIs?
If I remove mod_perl, can I use the
PerlSetEnv -I/var/www/html/mypath -I/var/www/html/mypath/lib
to achieve the same result.
This will make a profound effect on my CGI directory because whatever I installed will no longer affect the system perl module search path. In effect, this will make my application self contained and making trouble shooting make easier.
- C Chan
Re: question on startup.pl overriding perl search path
am 18.01.2008 15:22:04 von Adam Prime
c chan wrote:
> I use "PerlConfigRequire /var/www/html/mypath/startup.pl" in httpd.conf to recompile all the CGIs. Inside startup.pl, I added the line:
>
> use lib qw(. mylib);
>
> To me amazement, after all the CGI is precompiled, they start to look into the "." and "mylib" path for loading Perl Modules without even having the line [use lib qw(. mylib);] incorporated in each individual cgi script.
>
> Can someone explain to me why this is the case? Is the mod_perl startup.pl script simply becomes the parent apache process for all the preloaded CGIs?
This is normal. Under mod_perl the perl interpreter just keeps running
until the apache child dies your modified @INC stays modified. I'm sure
someone with a better understanding of the internals can give a more
detailed 'why'. FYI though, you should probably use PerlPostConfigRequire
http://perl.apache.org/docs/2.0/user/config/config.html#C_Pe rlPostConfigRequire_
> If I remove mod_perl, can I use the
>
> PerlSetEnv -I/var/www/html/mypath -I/var/www/html/mypath/lib
>
> to achieve the same result.
Isn't PerlSetEnv part of mod_perl? In which case, no that wouldn't work
if you'd removed mod_perl
> This will make a profound effect on my CGI directory because whatever I installed will no longer affect the system perl module search path. In effect, this will make my application self contained and making trouble shooting make easier.
>
> - C Chan
Adam
Re: question on startup.pl overriding perl search path
am 20.01.2008 06:43:14 von c chan
-----Original Message-----
>From: Adam Prime
>Sent: Jan 18, 2008 6:22 AM
>To: c chan
>Cc: modperl@perl.apache.org
>Subject: Re: question on startup.pl overriding perl search path
>
>c chan wrote:
>> I use "PerlConfigRequire /var/www/html/mypath/startup.pl" in httpd.conf to recompile all the CGIs. Inside startup.pl, I added the line:
>>
>> use lib qw(. mylib);
>>
>> To me amazement, after all the CGI is precompiled, they start to look into the "." and "mylib" path for loading Perl Modules without even having the line [use lib qw(. mylib);] incorporated in each individual cgi script.
>>
>> Can someone explain to me why this is the case? Is the mod_perl startup.pl script simply becomes the parent apache process for all the preloaded CGIs?
>
>This is normal. Under mod_perl the perl interpreter just keeps running
>until the apache child dies your modified @INC stays modified. I'm sure
>someone with a better understanding of the internals can give a more
>detailed 'why'. FYI though, you should probably use PerlPostConfigRequire
>
>http://perl.apache.org/docs/2.0/user/config/config.html#C_P erlPostConfigRequire_
>
>> If I remove mod_perl, can I use the
>>
>> PerlSetEnv -I/var/www/html/mypath -I/var/www/html/mypath/lib
>>
>> to achieve the same result.
>
>Isn't PerlSetEnv part of mod_perl? In which case, no that wouldn't work
>if you'd removed mod_perl
Thank you for your clarification. To make the CGI scripts both work under Apache and mod_perl, I put the "use lib qw(...);" in everyone of them.
- Clement
>
>> This will make a profound effect on my CGI directory because whatever I installed will no longer affect the system perl module search path. In effect, this will make my application self contained and making trouble shooting make easier.
>>
>> - C Chan
>
>Adam