***** infoCopter.com/perl *****

mod_perl



[ mod_perl ] - [ mod_perl Basic Auth Challenge ] - [ Apache Request Loop ]

Hello World Sample

package ModPerl::Hello;

use strict;
use warnings;

use Apache::RequestRec ();
use Apache::RequestIO ();

use Apache::Const -compile => qw(OK);

sub handler {
      my $r = shift;

      $r->content_type('text/html');

	print q~<html>
	<head><title>mod_perl</title>
	</head>
	<body>
	<h1>mod_perl 2.0 rocks!</h1>
	<ul>
	~;

	print "<li>$_ = $ENV{$_}</li>\n" foreach keys %ENV;

	print '</ul>';

	return Apache::OK;
}

1;


httpd.conf:

<Location /hello/world>
	SetHandler  perl-script
	PerlHandler ModPerl::Hello
</Location>

[ http://perl.apache.org/docs/2.0/user/intro/start_fast.html ] - [ CGI to mod_perl ]



Check if script is running in mod_perl mode:

Check if $ENV{MOD_PERL} is set. This is what Apache::DBI does.

Or check with $ENV{GATEWAY_INTERFACE}

Common CGI: "CGI/1.1" / mod_perl: "CGI-Perl/1.1"


Module Directives:

PerlSwitches - Perl Switches
PerlModule - PerlModule
PerlRequire - PerlRequire
PerlOptions - Perl Options
PerlInitHandler - Subroutine name
PerlSetVar - PerlSetVar
PerlAddVar - PerlAddVar
PerlSetEnv - PerlSetEnv
PerlPassEnv - PerlPassEnv
Perl Code
Perl - Perl Code
PerlSetInputFilter - filter[;filter]
PerlSetOutputFilter - filter[;filter]
=pod - Start of POD
=back - End of =over
=cut - End of POD
__END__ - Stop reading config
PerlLoadModule - A Perl module
PerlSendHeader - Tell mod_perl to scan output for HTTP headers
PerlSetupEnv - Turn setup of %ENV On or Off
PerlHandler - Subroutine name
PerlTaintCheck - Turn on -T switch
PerlWarn - Turn on -w switch
PerlChildInitHandler - Subroutine name
PerlChildExitHandler - Subroutine name
PerlOpenLogsHandler - Subroutine name
PerlPostConfigHandler - Subroutine name
PerlPreConnectionHandler - Subroutine name
PerlProcessConnectionHandler - Subroutine name
PerlHeaderParserHandler - Subroutine name
PerlAccessHandler - Subroutine name
PerlAuthenHandler - Subroutine name
PerlAuthzHandler - Subroutine name
PerlTypeHandler - Subroutine name
PerlFixupHandler - Subroutine name
PerlResponseHandler - Subroutine name
PerlLogHandler - Subroutine name
PerlCleanupHandler - Subroutine name
PerlInputFilterHandler - Subroutine name
PerlOutputFilterHandler - Subroutine name
PerlPostReadRequestHandler - Subroutine name
PerlTransHandler - Subroutine name
PerlMapToStorageHandler - Subroutine name


Related Links

Fast Start Introduction to mod_perl

  1. modperl.com:9000/book/chapters/ch9.html (Perl)
    http://modperl.com:9000/book/chapters/ch9.html
    Chapter 9: Perl API Reference Guide (2004-11-01 17:10)

  2. BlackPerl.com/RPC::XML (Perl)
    http://www.blackperl.com/RPC::XML/
    An implementation of the XML-RPC standard in Perl. The goal is to provide a client, a stand-alone server and an Apache/mod_perl content-handler class (2004-05-13 15:40)

  3. Perl.Apache.org/docs/2.0/index.html (Perl)
    http://perl.apache.org/docs/2.0/index.html
    mod_perl 2.0 Documentation (2004-04-05 23:57)

  4. Perl.Apache.org/docs/2.0/user/porting/porting.html (Perl)
    http://perl.apache.org/docs/2.0/user/porting/porting.html
    Porting Apache:: Perl Modules from mod_perl 1.0 to 2.0 (2004-04-05 23:23)

  5. TAKE23.org/docs/guide/performance.xml/6 (Perl)
    http://take23.org/docs/guide/performance.xml/6
    news and resources for the mod_perl World (performance) (2004-02-14 18:00)

  6. LAMPS.efactory.de/lamps-2-0... (CInternet:Webmaster)
    http://lamps.efactory.de/lamps-2-0.shtml
    LAMPS Tutorial. Kompilieren, Installieren und
    Konfigurieren eines LAMPS Servers. Apache 2.0, Mod_Perl,
    PHP, Mod_SSL, MySQL, PostgreSQL und PDFLib in wenigen
    Schritten und anhand von Beispielen (2003-01-24 15:56)

  7. uwinnipeg.ca/.../cpan-search?request=search (Perl)
    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?request=search
    CPAN full text search tool (2002-07-03 14:56)

  8. modperl.com/perl_conference... (Perl)
    http://www.modperl.com/perl_conference/advanced/more_dbi.html
    Beispiele für Datenbankzugriffe mit Perl DBI (1999-09-14 15:38:08)

© reto :)