Michael Kraus wrote: > If a sublass has overrides a method in a superclass, and the > subclasses method calls the superclass's method, is there any > mechanism to detect that the superclass' method has been overridden? > > > I'm wanting to write a method in an abstract class that must be > overriden by it's children. If it is called directly (i.e. without > being overriden) then it registers an error, but if its called via an > overriding method then do some common functionality.
That's not an abstract class. Anyway, here's how to do it: sub foo { my $self = shift; my $class = ref $self; if ($class->can('foo') eq \&foo) { print "$class does not override foo\n"; } else { print "$class overrides foo\n"; } } See perldoc UNIVERSAL for caveats on the can() method. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>