package Encoder; ## Basic constructor sub new { my $type = shift; my $self = {}; bless $self, $type; } ## Define the common interface sub shared_stuff { return reverse $_[1]; } ## Define the uncommon interface sub other_stuff { die "Somebody didn't define the other stuff!"; } ## Generalized encoding method sub encode { my $self = shift; my ($text) = @_; $self->common_stuff($text); $self->other_stuff($text); }