> however when I run the following code
>
> #!c:/perl/bin/perl -w
> use Apache ();
> use Apache::Request ();
> use CGI::Carp qw(fatalsToBrowser);
> my $r = Apache::Request->new(shift);
> # my $apr = Apache::Request->new($r);
> print "Content-type:text/html\n\n";
> print "Hello, World...\n";
> print $r;
> print @INC;
>
> I receive the message
> Can't locate object method "new" via package "Apache::Request" (perhaps
> you forgot to load "Apache::Request"?) at c:\apache\cgi-bin\ap2.pl line
> 6.
mod_perl sends $r to the handler() subroutine by default. That is, if you're
using it in a PerlHandler context, like you should with anything that uses
Apache::Request.
Therefore, th ollowing should work for you.
#!/usr/bin/perl -w
use strict;
use Apache::Constants qw(:common);
sub handler {
my $r = shift;
my $result = undef;
eval { $result = inner_handler($r) };
return $result unless $@;
warn "Uncaught Exception: $@";
return SERVER_ERROR;
}
sub inner_handler {
my $r = shift;
$r->content-type('text/html');
$r->status(200);
my $html = "<html><head><title>Hello World!</title></head><body><center>You
Tried To Access URI: ". $r->uri ."</center></body></html>";
$r->send_http_header;
print $html;
}