Practical mod_perl / HTML Book /



previous page: 25.1.4. ModPerl::Registry Family
  
page up: HTML Version of the book
  
next page: 25.1.6. Apache::StatINC Replacement

25.1.5. Method Handlers


In mod_perl 1.0, method handlers had to be specified by using the ($$) prototype:

package Eagle;
@ISA = qw(Bird);

sub handler ($$) {
    my($class, $r) = @_;
    ...;
}

Starting with Perl Version 5.6, you can use subroutine attributes, and that's what mod_perl 2.0 does instead of conventional prototypes:

package Eagle;
@ISA = qw(Bird);

sub handler : method {
    my($class, $r) = @_;
    ...;
}

See the attributes manpage.

mod_perl 2.0 doesn't support the ($$) prototypes, mainly because several callbacks in 2.0 have more arguments than $r, so the ($$) prototype doesn't make sense any more. Therefore, if you want your code to work with both mod_perl generations, you should use the subroutine attributes.

 

Continue to:

  • prev: 25.1.4. ModPerl::Registry Family
  • Table of Contents
  • next: 25.1.6. Apache::StatINC Replacement







TOP
previous page: 25.1.4. ModPerl::Registry Family
  
page up: HTML Version of the book
  
next page: 25.1.6. Apache::StatINC Replacement


Menu

  • HTML Book
  • PDF Book
  • Download Code
  • Table of Contents
  • Errata
  • mod_perl2 User's Guide
  • Sitemap

Search


Add to Google




Creative Commons License


Written by
Eric Cholet (Logilune) and
Stas Bekman (StasoSphere & Free Books).


[ Privacy Policy | Terms of Use | About Us | Search ]

© 2007 StasoSphere.com