substr($str, $max - 3) = '...';
}
return $str;
}
# Takes two packages and an optional cache. Says whether the
# first inherits from the second.
#
# Recursive versions of this have to work to avoid certain
# possible endless loops, and when following long chains of
# inheritance are less efficient.
sub trusts {
my $child = shift;
my $parent = shift;
my $cache = shift || {};
my ($known, $partial) = get_status($cache, $child);
# Figure out consequences until we have an answer
while (@$partial and not exists $known->{$parent}) {
my $anc = shift @$partial;
next if exists $known->{$anc};
$known->{$anc}++;
my ($anc_knows, $anc_partial) = get_status($cache, $anc);
my @found = keys %$anc_knows;
@$known{@found} = ();
push @$partial, @$anc_partial;
}
return exists $known->{$parent};
}
# Takes a package and gives a list of those trusted directly
sub trusts_directly {
my $class = shift;
no strict 'refs';
no warnings 'once';
return @{"$class\::CARP_NOT"}
? @{"$class\::CARP_NOT"}
: @{"$class\::ISA"};
}
1;
=3=
THE END |