NEXT(3p) Perl Programmers Reference Guide NEXT(3p)
NEXT(3p) Perl Programmers Reference Guide NEXT(3p) # NEXT(3p) Perl Programmers Reference Guide NEXT(3p) NNAAMMEE # NEXT - Provide a pseudo-class NEXT (et al) that allows method redispatch SSYYNNOOPPSSIISS # use NEXT; package P; sub P::method { print "$_[0]: P method\n"; $_[0]->NEXT::method() } sub P::DESTROY { print "$_[0]: P dtor\n"; $_[0]->NEXT::DESTROY() } package Q; use base qw( P ); sub Q::AUTOLOAD { print "$_[0]: Q AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub Q::DESTROY { print "$_[0]: Q dtor\n"; $_[0]->NEXT::DESTROY() } package R; sub R::method { print "$_[0]: R method\n"; $_[0]->NEXT::method() } sub R::AUTOLOAD { print "$_[0]: R AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub R::DESTROY { print "$_[0]: R dtor\n"; $_[0]->NEXT::DESTROY() } package S; use base qw( Q R ); sub S::method { print "$_[0]: S method\n"; $_[0]->NEXT::method() } sub S::AUTOLOAD { print "$_[0]: S AUTOLOAD\n"; $_[0]->NEXT::AUTOLOAD() } sub S::DESTROY { print "$_[0]: S dtor\n"; $_[0]->NEXT::DESTROY() } package main; my $obj = bless {}, "S"; $obj->method(); # Calls S::method, P::method, R::method $obj->missing_method(); # Calls S::AUTOLOAD, Q::AUTOLOAD, R::AUTOLOAD # Clean-up calls S::DESTROY, Q::DESTROY, P::DESTROY, R::DESTROY DDEESSCCRRIIPPTTIIOONN # The "NEXT" module adds a pseudoclass named "NEXT" to any program that uses it. ...