use strict; package A; sub new { my $pkg = shift; bless {}, $pkg; } sub first { print "A::first\n"; } sub second { print "A::second\n"; } sub check { my $this = shift; my $pkg = ref $this; print "\nResults of check:\n"; foreach my $subname (qw(first SUPER::first second SUPER::second)) { if (defined (my $sub = $this->can ($subname))) { print ("$pkg can $subname\n"); $this->$sub (); } else { print "$pkg cannot do $subname\n"; } } } package A_sub; @A_sub::ISA = qw(A); sub first { print "A_sub::first\n"; } sub check_sub { my $this = shift; my $pkg = ref $this; print "\nResults of check_sub:\n"; foreach my $subname (qw(first SUPER::first second SUPER::second)) { if (defined (my $sub = $this->can ($subname))) { print ("$pkg can $subname\n"); $this->$sub (); } else { print "$pkg cannot do $subname\n"; } } } package main; my $asub = new A_sub; $asub->check (); $asub->check_sub ();