package SUPER::DISPATCH; our $AUTOLOAD; sub AUTOLOAD { my ($self, @args) = @_; my $a = $AUTOLOAD; my ($method) = ($a =~ /SUPER\:\:DISPATCH\:\:(.*)/); my $calling_package = caller(0); no strict 'refs'; my @callingISA = @{"${calling_package}::ISA"}; foreach my $superclass (@callingISA) { my $supermethod = $superclass->can($method); $supermethod->($self, @args) if $supermethod; } } package Base; sub new { bless {}, $_[0] } sub compile { my ($self) = @_; print("> compile called in Base by " . (caller())[0] . "\n") } package Filter; use base ('Base'); sub compile { my ($self) = @_; $self->SUPER::compile(); print("> compile called in Filter by " . (caller())[0] . "\n"); } package Safe; use base ('Base'); sub compile { my ($self) = @_; $self->SUPER::compile(); print("> compile called in Safe by " . (caller())[0] . "\n"); } package SafeFilter; use base ('Filter', 'Safe'); sub compile { my ($self) = @_; $self->SUPER::DISPATCH::compile(); print("> compile called in SafeFilter by " . (caller())[0] . "\n"); } package main; my $sf = SafeFilter->new(); $sf->compile(); __OUTPUT__ > compile called in Base by Filter > compile called in Filter by SUPER::DISPATCH > compile called in Base by Safe > compile called in Safe by SUPER::DISPATCH > compile called in SafeFilter by main