Joe Lewis wrote:
.
.
.
.
After a few minutes of searching for some example code and slapping it together, I have an apache configuration that demonstrates the use of mod_perl :

_________CODE_START________

LoadModule perl_module modules/mod_perl.so
PerlResponseHandler Apache2::example
SetHandler modperl

<Perl>
package Apache2::example;

use 5;
use strict;
use Apache2::RequestRec;
use Apache2::RequestIO;
use Apache2::Const -compile => qw(DECLINED OK LOG_DEBUG);
use Apache2::Log -compile => qw(LOG_MARK);
use APR::Const -compile => qw(ENOTIME);

sub handler {
 my $r = shift();
# $r->log_rerror(Apache2::Log::LOG_MARK, Apache2::Const::LOG_DEBUG, APR::Const::ENOTIME, "debug print");
 $r->log_error("debug print");

 if ($r->uri =~ m%^/my/uri/to/test%) {
   $r->content_type('text/html');
   $r->puts(<<"END");
<HTML><BODY>
<H3>Hello</H3>
Hello from <B>this</B>!
</BODY></HTML>
END

   return Apache2::Const::OK;
 }
 return Apache2::Const::DECLINED;
};

1;
</Perl>
_________CODE_FINISH________

Just paste that into a .conf file and include the .conf file into your apache. Then, restart, and point a web browser to your server using the URI of /my/uri/to/test (e.g. http://example.com/my/uri/to/test). You should get a simple "hello!", and see a "debug print" in your apache log file. Keep in mind, with a module name like "Apache2::Footer", you probably want it to alter the content of a page to add a footer rather than create the complete content.

After being distracted by other tasks, I have returned to this, done everything carefully, and now can proceed to debug the actual handler part.

Thanks!

Bernard Higonnet
PS I have left a copy of your helpful code for anyone coming upon it in a 
search.

Reply via email to