| Next | Tricks of the Wizards | 113 |
Here's a simplified version
First, a utility function:
sub class_structure {
my $start = shift;
my $prev;
my @todo = ($start);
my %next;
while (@todo) {
my $cur = shift @todo;
$next{$prev} = $cur if defined $prev;
unshift @todo, @{"$cur\::ISA"};
$prev = $cur;
}
\%next;
}
Given a class name, this returns a hash of 'next' classes
Given D it returns
{ D => B, B => A, A => C, C => undef }
Given B it returns
{ B => A, A => undef }
| Next | ![]() |
Copyright © 2003 M. J. Dominus |