Next | Tricks of the Wizards | 114 |
sub AUTOLOAD { my ($self_class) = ref $_[0] || $_[0]; my $cs = class_structure($self_class);
my $caller_class = caller; my $next_class = $caller_class;
my (undef, $method) = ($NEXT::AUTOLOAD =~ /(.*)::(.*)/);
do { $next_class = $cs->{$next_class}; } while defined $next_class && not defined &{"$next_class\::$method"} ;
if (defined $next_class) { goto &{"$next_class\::$method"}; } else { return; } }
We find out the class that the target object is in ($self_class)
We get the next-class table for that class ($cs)
We figure out where we were called from ($caller_class)
We scan $cs until we find a new class that has the method we want
Then we go to it
Next | Copyright © 2003 M. J. Dominus |