Hi,
I am new to mod_perl and am having problems seeing the
changes made to library files. Must I restart the server every
time I change a library file in order to see my changes? My
test code and environment is below.
z.pl - test script which calls entry_point in z_lib.pl
-------------------------------------------------------
#!/usr/local/bin/perl
use strict;
require '/home/cgi-bin/z_lib.pl';
&entry_point();
-------------------------------------------------------
z_lib.pl
----------------------
#!/usr/local/bin/perl
use strict;
sub entry_point {
my $r = Apache->request;
$r->content_type('text/html');
$r->send_http_header;
print "HERE 1";
#print " HERE 2";
}
1;
------------------
My Test Procedure:
1.) Start server (w/ -X option)
2.) Run z.pl via browser - output is "HERE 1"
3.) Uncomment out second print statement in z_lib.pl
4.) Reload z.pl via browser - output is "HERE 1"
I would expect it to display the output of
the second print statement, but it does not.
5.) Re-start server
6.) Run z.pl via browser - output is "HERE 1 HERE 2"
If I deliberately put an error in z_lib.pl and reload z.pl, I receive
an error message. So, it appears that the library file z_lib.pl is
getting reloaded. But why don't my changes show up? Also,
here is the output in the error_log that displays Apache::StatINC
messages
Apache::StatINC: process 21891 reloading /home/cgi-bin/z_lib.pl.
Apache::StatINC::handler('Apache=SCALAR(0x211220)') called at /dev/null
line 0 eval {...} called at /dev/null line 0
I have extended @INC by using "use lib .." in the startup file. I
have read through the mod_perl guide at http://apache.perl.org/, but
am unable to resolve this problem. Should I replace the 'require's
with 'do's in development and then switch back to requires when
moving to production?
My Environment:
perl version: 5.6.1
mod_perl version: 1.26
apache version: 1.3.24
OS: Solaris 2.8
from httpd.conf
----------------
PerlWarn On
PerlModule Apache::StatINC
PerlRequire /httpd/conf/startup.pl
Alias /cgi-bin/ /home/cgi-bin/
PerlModule Apache::Registry
<Location /cgi-bin>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
allow from all
PerlSendHeader On
PerlInitHandler Apache::StatINC
PerlSetVar StatINC_Debug 1
</Location>
----------------
startup.pl
---------------
use strict;
# Extend @INC if needed
use lib qw(/home/cgi-bin);
# Make sure we are in a sane environment.
$ENV{MOD_PERL} or die "not running under mod_perl!";
# Don't include the name of the virtual host in the package name
$Apache::Registry::NameWithVirtualHost = 0;
# Load Perl modules of your choice here
# This code is interpreted *once* when the server starts
use Apache::DBI ();
use DBI ();
# Tell me more about warnings
use Carp ();
$SIG{__WARN__} = \&Carp::cluck;
1;
---------------
Thanks for any help you can provide,
Ted