Empty $r in mod_perl

Empty $r in mod_perl

am 06.01.2007 11:42:45 von jason.yfho

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

.......
Options Indexes FollowSymLinks ExecCGI
PerlHandler Apache2::Registry
PerlSendHeader On
.......



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

Re: Empty $r in mod_perl

am 06.01.2007 13:18:34 von Thomas Wittek

jason.yfho@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@jabber.i-pobox.net