package Any; sub new { my $class=shift; bless {},$class } sub name { my $self=shift; my $type=$self->type; $self->{$type}{name}=shift if @_; $self->{$type}{name}; } sub mirror { my $self=shift; my $other=$self->other; my $type=$self->type; $self->{other}= delete $self->{type}; bless $_[0],$other; } sub type { 'neither' }; sub other { 'Any' }; package Leftie; @ISA=qw(Any); sub type { 'left' }; sub other { 'Rightie' }; 1; package Rightie; @ISA=qw(Any); sub type { 'right' }; sub other { 'Leftie' } 1;