home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Writing Apache Modules with Perl and C
By:   Lincoln Stein and Doug MacEachern
Published:   O'Reilly & Associates, Inc.  - March 1999

Copyright © 1999 by O'Reilly & Associates, Inc.


 


   Show Contents   Previous Page   Next Page

Chapter 9 - Perl API Reference Guide / Other Core Perl API Classes
The mod_perl Class

Among the packages installed by the Perl API is a tiny one named, simply enough, mod_perl. You can query this class to determine what version of mod_perl is installed and what features it makes available.

import()

If your Apache Perl API modules depend on version-specific features of mod_perl, you can use the import() method to require that a certain version of mod_perl be installed. The syntax is simple:

use mod_perl 1.16; # require version 1.16 or higher

When mod_perl is built, you can control which handlers and other features are enabled. At runtime, import() can be used to check for the presence of individual features.

# require Authen and Authz handlers to be enabled
use mod_perl qw(PerlAuthenHandler PerlAuthzHandler);

If any of these features are not active, the use operator will fail. Here is the list of features that you can check for:

PerlDispatchHandler
PerlFixupHandler
PerlChildInitHandler
PerlHandler
PerlChildExitHandler
PerlLogHandler
PerlPostReadRequestHandler
PerlInitHandler
PerlTransHandler
PerlCleanupHandler
PerlHeaderParserHandler
PerlStackedHandlers
PerlAccessHandler
PerlMethodHandlers
PerlAuthenHandler
PerlDirectiveHandlers
PerlAuthzHandler
PerlSections
PerlTypeHandler
PerlSSI

hook()

The hook() function can be used at runtime to determine whether the current mod_perl installation provides support for a certain feature. This is the internal function that import() uses to check for configured features. This function is not exported, so you have to refer to it using its fully qualified name, mod_perl::hook(). hook() recognizes the same list of features that import() does.

use mod_perl ();
unless(mod_perl::hook('PerlAuthenHandler')) {
  die "PerlAuthenHandler is not enabled!";
}
   Show Contents   Previous Page   Next Page
Copyright © 1999 by O'Reilly & Associates, Inc.