use warnings; use strict; package Frobnicate::Bar; sub new { my ($class) = @_; return bless {}, $class; } sub sayWhat { my ($self) = @_; if (ref $self) { print "I'm a ", ref $self, " method\n"; } else { print "I'm a ", __PACKAGE__, " function\n"; } } package Frobnicate::Foo; our @ISA = qw/Frobnicate/; sub new { my ($class) = @_; return Frobnicate::new ($class); } sub sayWhat { my ($self) = @_; if (ref $self) { print "I'm a ", ref $self, " method\n"; } else { print "I'm a ", __PACKAGE__, " function\n"; } } package Frobnicate; sub new { my ($class) = @_; return bless {}, $class; } sub sayWhat { my ($self) = @_; if (ref $self) { print "I'm a ", ref $self, " method\n"; } else { print "I'm a ", __PACKAGE__, " function\n"; } } 1;