Stas Bekman wrote: > Tim Noll wrote: > > Is there a proper way to call a method handler using either push_handlers or > > set_handlers? They both appear to call all handler refs just like normal > > subs, with no class name passed in. It appears that enclosing the handler in > > an anonymous sub is a workaround, but I was wondering if there was a better > > solution. > > > > # does not call handler as a method > > $r->push_handlers( PerlHandler => \&Apache::Test::handler ); > > > > # does call handler as a method > > $r->push_handlers( PerlHandler => sub { Apache::Test->handler } ); > > See > > http://perl.apache.org/guide/config.html#Perl_Method_Handlers, the eagle > and cookbook books. > > PERL_METHOD_HANDLERS=1 + $$ prototype for Apache::Test::handler
My question was really about the proper way to call method handlers from either push_handlers or set_handlers since the normal technique (first example above) calls them as normal subs, i.e. the first parameter is not the class name. The second example, however, seems to do the trick. I just wanted to know whether there was a better technique and/or any pitfalls to this technique. While searching around the web a bit more today, I came across the example below from the mod_perl_method_handlers man page, which seems to be similar, so I guess I'm on the right track. However, any comments would still be appreciated. <snip> $r->push_handlers(PerlHandler => sub { my $r = shift; $self->perl_handler_method($r); } ); </snip> -Tim