O'Reilly logo

Writing Apache Modules with Perl and C by Lincoln Stein, Doug MacEachern

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A.7. The Apache::StatINC Class

When you write a script using the Apache::Registry mechanism, Apache::Registry watches the script file's modification date and reloads the script if it is more recent than the compiled version in memory. This lets you edit the script file and see the changes immediately.

However, this is not the case with Apache Perl API modules or any Perl library files that they depend on. Changing the .pm file does not cause the module to be reloaded automatically. You ordinarily have to restart the whole server with apachectl restart or apache -k restart to see any changes take effect.

You can use the Apache::StatINC to alter this behavior. Each time it runs, Apache::StatINC checks the contents of the Perl global %INC hash of loaded modules. Apache::StatINC keeps track of each module's modification time. When it notes that a module has been modified since it was last loaded, it removes the module from %INC, forcing Perl to reload and compile it.

To install Apache::StatINC, add the following configuration directive to perl.conf (or any of the configuration files):

PerlInitHandler Apache::StatINC

This directive arranges for Apache::StatINC 's handler() method to be invoked every time Apache handles an HTTP request, before any other Perl*Handlers are run.

Note that Apache::StatINC only sees the directories that were present in the @INC include path at the time the server was started. During a request, a script or module may modify the @INC path, but those changes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required