Dynamic Pages with mod_perl

During "response phase" dynamic document is created and sent to browser. This is also when CGI scripts run.

The Simple Way

Put Apache::Registry in charge of your cgi-bin directory.

All CGI scripts will now load much faster. Example for srm.conf:

<Location /cgi-bin>
  SetHandler  perl-script
  PerlHandler Apache::Registry
  PerlSendHeader On
  Options +ExecCGI
</Location>

The Powerful Way

Entry for srm.conf:
 <Location /hello/world>
    SetHandler  perl-script
    PerlHandler Apache::Hello
  </Location>

Script III.1.1 Apache::Hello

 package Apache::Hello;
 # file: Apache/Hello.pm

 use strict vars;
 use Apache::Constants ':common';

 sub handler {
     my $r = shift;
     $r->content_type('text/html');
     $r->send_http_header;
     my $host = $r->get_remote_host;
     $r->print(<<END);
 <HTML>
 <HEADER>
 <TITLE>Hello There</TITLE>
 </HEADER>
 <BODY>
 <H1>Hello $host</H1>
 Hello to all the nice people at the Perl conference.  Lincoln is
 trying really hard.  Be kind.
 </BODY>
 </HTML>
 END
     return OK;
 }
 1;

What it Looks Like

http://localhost/hello/world
<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Mon Aug 17 10:48:45 EDT 1998