in reply to checking a method is not subclassed
You need to be careful though - perl supports multiple inheritance, so you may need to figure out your subclasses and then figure out all of their parent classes to find all the other roots of the inheritance tree. And if you do have multiple inheritance, I can't think of any way of telling that this subroutine came from that superclass and that this other subroutine came from that other superclass.
package Foo; sub foo { 'foo' } package Bar; # Bar inherits 'foo' from Foo @ISA = qw(Foo); sub bar { 'bar' } # Bar defines 'bar' package main; use Class::CanBeA; my @subclasses = @{Class::CanBeA::subclasses('Foo')}; foreach my $class (@subclasses) { print "$class is a subclass of Foo\n"; foreach my $sub (qw(foo bar)) { if(!exists(&{$class.'::'.$sub}) && $class->can($sub)) { print $class.'::'.$sub." is inherited\n"; } } }
|
|---|