perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: API Docs
Date Fri, 16 May 2014 09:09:08 GMT
Worik Stanton wrote:
> I am still trying to fathom the API.
> 
> I have struck a snag with the documentation.
> 
> 
> https://perl.apache.org/docs/2.0/api/Apache2/Connection.html#Synopsis
> says....
> 
>   use Apache2::Connection ();
>   use Apache2::RequestRec ();
> 
>   my $c = $r->connection;
> 
> 
> What is $r?
> 
> I am missing something obvious, what is the context here I do not get?
> 
Hi.

Maybe you should start here : 
https://perl.apache.org/docs/2.0/user/handlers/intro.html#What_are_Handlers_

$r is the "current request object".  How you obtain it varies a bit depending on where you

are (in a mod_perl handler, in a cgi-bin script etc..).
Usually, you'll be in some kind of handler() sub, and the usual idiom then is just

sub handler {
  my $r = shift;
..
}

as the request object is the first and usually the only parameter passed in such a sub/method.
It is also usually the starting point for everything else in mod_perl.

If you are a real beginner, a recommendation : persist, you'll soon get the hang of it, 
and it's worth the effort.  Perl is fun; Apache + mod_perl is *a lot* of fun, and 
incredibly powerful.


Mime
View raw message