in reply to Redefining methods in non-singletons nearly drove me mad today

Virtual Method Table (VMT) are per-class, not per-object. But then again, Perl doesn't use VMTs.

C++ knows which method to call by storing the object's class's VMT in the object.
Perl knows which method to call by storing the object's class's name in the object.

What you are manipulating is Perl's symbol table. Adding functions to a package will affect all objects of that class.

It is possible to do what you want with overload magic (I think), or by using less obvious syntax. Here's a couple of quick and dirty ways:

sub new { my ($class, $name) = @_; my $self = bless({ name => $name, getName => \&showName, }, $class); return $self; } $self->{getName}->();
or
sub new { my ($class, $name) = @_; my $self = bless({ name => $name, getName => 'showName', }, $class); return $self; } sub getName { my $self = $_[0]; my $method = $self->{getName}; $self->$method(@_); } $self->getName();