Empty $r in mod_perl

Dear All,

I installed mod_perl 2 (static mod) in my linux, however, seems the
perl script cannot invoke the mod_perl's function. anyone can give me
some ideaa on the problem? My purpose of using mod_perl is the get the
full header of all HTTP request to Apache. Thank you so much! Below is
the scenario:


System:
- Fedora 3
- Apache 2.2.3
- Perl 5.8.8


I added the following in httpd.conf:
PerlModule Apache2::Registry
<Directory "/usr/local/apache2/htdocs">
.......
Options Indexes FollowSymLinks ExecCGI
PerlHandler Apache2::Registry
PerlSendHeader On
.......
</Directory>


When apache starts, the error_log shows:
[Sat Jan 06 18:43:54 2007] [notice] Apache/2.2.3 (Unix) mod_perl/2.0.3
Perl/v5.8.8 configured -- resuming normal operations


My perl script in "/usr/local/apache2/htdocs/test1.pl":
#!/usr/local/bin/perl5.8.8
use strict;
my $r = shift;
$r->print("It worked!!!\n");


The following error in error_log:
[Sat Jan 06 18:44:32 2007] [error] [client 192.168.1.35] Can't call
method "print" on an undefined value at
/usr/local/apache2/htdocs/test1.pl line 8.


Regards,
Jason
jason.yfho [ Sa, 06 Januar 2007 11:42 ] [ ID #1587132 ]

Re: Empty $r in mod_perl

jason.yfho [at] gmail.com schrieb:
> My perl script in "/usr/local/apache2/htdocs/test1.pl":
> #!/usr/local/bin/perl5.8.8
> use strict;
> my $r = shift;
> $r->print("It worked!!!\n");

I had to do this in my Apache2 handler:

require Apache2::RequestUtil;
Apache2::RequestUtil->request($r);

$r->print("It worked!!!\n");

Maybe it works for you.
--
Thomas Wittek
http://gedankenkonstrukt.de/
Jabber: streawkceur [at] jabber.i-pobox.net
Thomas Wittek [ Sa, 06 Januar 2007 13:18 ] [ ID #1587133 ]
Perl » comp.lang.perl.modules » Empty $r in mod_perl

Vorheriges Thema: PayPal Reporting API
Nächstes Thema: New module for testing