Re: API Docs

André Warnier <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.