{ package Animal; use Carp; use overload(); sub new { my $class = shift; my $name = shift; bless \$name, $class; } sub name { my $self = shift; ref $self ? $$self : "an unnamed $self"; } sub speak { my $class = shift; print "a $$class goes ", $class->sound, "!\n"; } sub eat { my $self = shift; my $food = shift; print $self->name, " eats $food.\n"; } my $private_method = sub { my $self = shift; print "From private method\n"; }; sub Private_Method { my $self = shift; print "kk::$self->{private_var}\n"; if (0 == index overload::StrVal($self), __PACKAGE__,0) { $self->$private_method(); } } } { package Horse; use vars '@ISA'; @ISA = qw (Animal); sub sound {"neigh"}; } { package Sheep; use vars '@ISA'; @ISA = qw (Animal); sub sound {"blahhhhhhhh"}; } my $horse1 = Horse->new("H1"); $horse1->speak; print "Horse sounds ", Horse->sound, "\n"; $horse1->eat("hay"); Sheep->eat("grass"); Sheep->speak(); #$horse1->Private_Method; #I can not access this Animal->Private_Method;