perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From René Seindal <>
Date Tue, 28 Mar 2000 00:30:19 GMT
I just got bitten by the problem of Apache::StatINC not reloading
modules found through an element of @INC, which is no longer present
when StatINC runs. This happens when a module adds a private directory
to @INC, which is then reset by mod_perl after the request is done.

This problem is mentioned in the mod_perl guide at

If you load a module, say, from . then $INC{''} eq
'', and StatINC won't be able to find it.  This is easily solved

use Cwd;
use lib Cwd::cwd;

which puts the current working directory in the path.  Make the obvious
adjustments if you use a subdirectory. Now the local modules will load
from $CWD (full path) and not from . (relative path), and %INC will hold
the absolute path name of locally found modules.

The next problem is that Apache::StatINC won't reload your modules
anyway.  StatINC scans %INC and stats all the files, and when one is out
of date, it does a require() on the module name. This fails, because the
directory of the module is no longer in the path. Yet StatINC knows the
filename, because it could do a stat on it.

A small change to StatINC solves the problem. Since StatINC could stat
the file, the file is accessible, only not through require(). The fix is
to change StatINC to load the file instead of the module, which is
achieved with this little patch (against 1.06 from mod_perl 1.21, but
nothing seems to have changed):

*** 25,32 ****
                my $class = Apache::Symbol::file2class($key);
                 $class->Apache::Symbol::undef_functions( undef, 1 );
!           delete $INC{$key};
!           require $key;
            warn "Apache::StatINC: process $$ reloading $key\n"
                  if $DEBUG;
--- 25,33 ----
                my $class = Apache::Symbol::file2class($key);
                 $class->Apache::Symbol::undef_functions( undef, 1 );
!           # delete $INC{$key};
!           # require $key;
!           do $INC{$key};
            warn "Apache::StatINC: process $$ reloading $key\n"
                  if $DEBUG;

Presumably one could do a 'do $file' as well, which would be a bit

René Seindal (

View raw message