You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mag Gam <ma...@gmail.com> on 2008/02/10 07:57:43 UTC

Trying to configure Apache2::Request

I have installed Apache2::Request via CPAN, but i keep getting this message
in my error_log

[error] Global symbol "$r" requires explicit package name at
/var/www/perl/doc.pl line 10.\n

Apache configuration looks like this:
LoadModule perl_module modules/mod_perl.so
LoadModule apreq_module   modules/mod_apreq2.so


<Directory /var/www/perl>
    AddHandler perl-script .pl
    PerlResponseHandler ModPerl::Registry Apache2::Request
    PerlOptions +ParseHeaders +GlobalRequest
    Options +ExecCGI
    DirectoryIndex new_home.pl
</Directory>
    PerlModule Apache2::Request



doc.pl looks like this:
#!/usr/bin/perl -w
use strict;
use CGI;
use APR::Request::Apache2 ();


print "Content-type: text/html\n\n";
print "Hello";

my $req = Apache2::Request->new($r, POST_MAX => "1M");


Any thoughts?

TIA

Re: Trying to configure Apache2::Request

Posted by Perrin Harkins <pe...@elem.com>.
On Feb 10, 2008 12:14 PM, Mag Gam <ma...@gmail.com> wrote:
>  my Apache2::Request $r = shift;
> Tells the Perl compiler to expect an object in the C<Apache2::Request>
> class to be assigned to C<$r>.  A patch has already been submitted to
> use this information so method calls can be resolved at compile time.

That didn't work out.  You should not do this.  Just use the normal
"my $r" syntax.

- Perrin

Re: Trying to configure Apache2::Request

Posted by Mag Gam <ma...@gmail.com>.
Nice, Thanks!

Just figured this out...



A known disadvantage to Perl method calls is that they are slower than
direct function calls.  It is possible to resolve method calls at
compile time, rather than runtime, making method calls just as fast as
subroutine calls.  However, there is certain information required for
method look ups that are only known at runtime.  To work around this,
compile-time hints can be used, for example:
 my Apache2::Request $r = shift;
Tells the Perl compiler to expect an object in the C<Apache2::Request>
class to be assigned to C<$r>.  A patch has already been submitted to
use this information so method calls can be resolved at compile time.
However, the implementation does not take into account sub-classing of
the typed object.  Since the mod_perl API consists mainly of methods,
it would be advantageous to re-visit the patch to find an acceptable
solution.




On Feb 10, 2008 12:06 PM, Perrin Harkins <pe...@elem.com> wrote:

> On Feb 10, 2008 1:57 AM, Mag Gam <ma...@gmail.com> wrote:
> > doc.pl looks like this:
> > #!/usr/bin/perl -w
> >  use strict;
> > use CGI;
> > use APR::Request::Apache2 ();
> >
> >
> > print "Content-type: text/html\n\n";
> > print "Hello";
>
> my $r = shift;
>
> > my $req = Apache2::Request->new($r, POST_MAX => "1M");
>
> Also, don't print your Content-type header.  Use CGI or $r to do it.
>
> - Perrin
>

Re: Trying to configure Apache2::Request

Posted by Perrin Harkins <pe...@elem.com>.
On Feb 10, 2008 1:57 AM, Mag Gam <ma...@gmail.com> wrote:
> doc.pl looks like this:
> #!/usr/bin/perl -w
>  use strict;
> use CGI;
> use APR::Request::Apache2 ();
>
>
> print "Content-type: text/html\n\n";
> print "Hello";

my $r = shift;

> my $req = Apache2::Request->new($r, POST_MAX => "1M");

Also, don't print your Content-type header.  Use CGI or $r to do it.

- Perrin