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;
####
use strict;
use warnings;
use noname1;
Frobnicate::Bar->new ()->sayWhat ();
Frobnicate::Foo->new ()->sayWhat ();
Frobnicate->new ()->sayWhat ();
Frobnicate::Bar::sayWhat ();
Frobnicate::Foo::sayWhat ();
Frobnicate::sayWhat ();
##
##
I'm a Frobnicate::Bar method
I'm a Frobnicate::Foo method
I'm a Frobnicate method
I'm a Frobnicate::Bar function
I'm a Frobnicate::Foo function
I'm a Frobnicate function