SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 5.X mod_perl-1.11-3.i386.rpm

lib::Apache::Registry

Section: User Contributed Perl Documentation (3)
Updated: mod_perl-1.11
Indexsub compile {
    my $eval = shift;
    Apache->untaint($eval);
    eval $eval;}

#XXX not good enough yetmy(%switches) = (
   'T' => sub {
       Apache::warn("Apache::Registry: T switch ignored, ".                 "enable with 'PerlTaintCheck On'\n")
         unless $Apache::__T; "";

   },
   'w' => sub { 'BEGIN {$^W = 1;}' },);

sub parse_cmdline {
    my $sub = shift;
    my($line) = $sub =~ /^(.*)$/m;
    my(@cmdline) = split /\s+/, $line;
    return $sub unless @cmdline;
    return $sub unless shift(@cmdline) =~ /^\#!/;
    my($s, @s$prepend);
    $prepend = "";
    for $s (@cmdline) {        next unless $s =~ s/^-//;
        last if substr($s,0,1) eq "-";
        for (split //, $s) {
         next unless $switches{$_};
         #print STDERR "parsed `$_' switch\n";
         $prepend .= &{$switches{$_}};
        }

    }
    $sub =~ s/^/$prepend/ if $prepend;
    return $sub;}

#trick so we show up under CPAN/modules/by-module/CGI/package CGI::mod_perl;

sub DESTROY {}

1;

__END__ 

NAME

Apache::Registry - Run unaltered CGI scrips under mod_perl 

SYNOPSIS

 #in httpd.conf
 Alias /perl/ /perl/apache/scripts/ #optional PerlModule Apache::Registry
 <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI  ... </Directory>
 

DESCRIPTION

URIs in the form of http://www.host.com/perl/file.pl will becompiled as the body of a perl subroutine and executed. Each serverprocess or `child' will compile the subroutine once and store it inmemory. It will recompile it whenever the file is updated on disk.Think of it as an object oriented server with each script implementinga class loaded at runtime.

The file looks much like a ``normal'' script, but it is compiled or `evaled'into a subroutine.

Here's an example:

 my $r = Apache->request; $r->content_type("text/html"); $r->send_http_header; $r->print("Hi There!");
This module emulates the CGI environment,allowing programmers to write scripts that run under CGI ormod_perl without change. Existing CGI scripts may require somechanges, simply because a CGI script has a very short lifetime of oneHTTP request, allowing you to get away with ``quick and dirty''scripting. Using mod_perl and Apache::Registry requires you to bemore careful, but it also gives new meaning to the word ``quick''!

Be sure to read all mod_perl related documentation for more details,including instructions for setting up an environment that looks exactlylike CGI:

 print "Content-type: text/html\n\n"; print "Hi There!";
Note that each httpd process or ``child'' must compile each script once,so the first request to one server may seem slow, but each requestthere after will be faster. If your scripts are large and/or make useof many Perl modules, this difference should be noticeable to the humaneye. 

SECURITY

Apache::Registry::handler will preform the same checks as mod_cgibefore running the script. 

ENVIRONMENT

The Apache function `exit' overrides the Perl core built-in function.

The environment variable GATEWAY_INTERFACE is set to CGI-Perl/1.1. 

COMMANDLINE SWITCHES IN FIRST LINE

Normally when a Perl script is run from the command line or under CGI,arguments on the `#!' line are passed to the perl interpreter for processing.

Apache::Registry currently only honors the -w switch and will turnon warnings using the $^W global variable. Another common switchused with CGI scripts is -T to turn on taint checking. This canonly be enabled when the server starts with the configurationdirective:

 PerlTaintCheck On
However, if taint checking is not enabled, but the -T switch is seen,Apache::Registry will write a warning to the error_log. 

DEBUGGING

You may set the debug level with the $Apache::Registry::Debug bitmask

 1 => log recompile in errorlog 2 => Apache::Debug::dump in case of $@ 4 => trace pedantically
 

CAVEATS

Apache::Registry makes things look just the CGI environment, however, youmust understand that this *is not CGI*. Each httpd child will compileyour script into memory and keep it there, whereas CGI will run it once,cleaning out the entire process space. Many times you have heard``always use -w, always use -w and `use strict'''.This is more important here than anywhere else!

Your scripts cannot contain the __END__ or __DATA__ token to terminatecompilation. 

SEE ALSO

perl(1), mod_perl(3), Apache(3), Apache::Debug(3) 

AUTHORS

Andreas J. Koenig and Doug MacEachern


 

Index

NAME
SYNOPSIS
DESCRIPTION
SECURITY
ENVIRONMENT
COMMANDLINE SWITCHES IN FIRST LINE
DEBUGGING
CAVEATS
SEE ALSO
AUTHORS

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector