On Thu, 20 Apr 2000, Doug MacEachern wrote:

> On Fri, 14 Apr 2000, Stas Bekman wrote:
> 
> >   use vars qw($q $switch $status $sessionID);
> 
> why all the globals??  symbol table lookups are much slower than lexicals.
> please don't promote globals, pass lexicals to the subroutines.

Yeah, I'll fix that. Just wanted to make the example less messy :)

> >   sub handler{
> >     my $r = shift;
> >     Apache->request($r);
> 
> you actually don't need to do that anymore as of 1.22

Oh, that's why -- I've tried without it and worked!

So this (attached) section is to be deleted now as a non-relevant?

=head1 Accessing the Request Object in non-Perl*Handler Modules

C<Perl*Handler>s can obtain a reference to the request object when it
is passed to them via C<@_>. For example:

  sub handler {
    my $r = shift;
    # ... some code
    return OK;
  }

In C<Apache::Registry> scripts (and friends), the request object
is available through the C<Apache-E<gt>request($r)> method. For example:

  my $r = Apache->request;
  print $r->uri;

In order to make the above work, C<Apache::Registry> internally passes
the original object to C<Apache-E<gt>request($r)> (transparantly to
the its users). It does:

    sub handler {
    my $r = shift;
    Apache->request($r);
    # ... lots of voodoo code :)
    return OK;
  }

Some modules, like C<CGI.pm>, rely on the fact that
C<Apache-E<gt>request()> will retrieve the request object. So when you
use these modules with a script running under C<Apache::Registry> (and
friends) everything is fine. However if you write your own
C<Perl*Handler> you should explicitly write C<Apache-E<gt>request($r)>
to make these modules work, just like in the above code snippet.



______________________________________________________________________
Stas Bekman             | JAm_pH    --    Just Another mod_perl Hacker
http://stason.org/      | mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]  | http://perl.org    http://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
----------------------------------------------------------------------

Reply via email to