Hello!
It's been about four years since I've used mod_perl to any great extent,
and I'm afraid I'm somewhat rusty. I'm trying to create a handler that
can parse CGI parameters, but I'm unsure of the most modern way of doing
that.
I know Apache2::Request is supposed to be able to grab CGI parameters;
is that "better" than using CGI.pm? How about these APR modules that
seem to wind their way into the framework?
When I tried creating an Apache2::Request->new($r) object to use to get
CGI parameters, I found that everything I tried to print after the
object's instantiation wouldn't show up anywhere. All the pages served
were zero bytes, and I couldn't even print to STDERR.
Here's a simple handler I wrote. It works, but I'm afraid I might be
doing something incorrectly by mixing Apache2 and CGI. I'm wondering
how it would look if someone who was more up-to-date on mod_perl wrote
it? :)
# BEGIN CODE BLOCK
use Apache2::Const -compile => qw(OK);
use CGI;
sub handler
{
my ($r) = @_;
my $cgi = CGI->new($r);
$r->content_type('text/html');
if (defined $cgi->param('foo'))
{
print 'foo: ' . $cgi->param('foo') . "<br />\n";
}
return Apache2::Const::OK;
}
# END CODE BLOCK
Thanks. :)
Colin