package Track; our %switch = (); # to be filled in by subclasses. sub new { my ($class) = @_; # don't have any args in mind yet. my $this = bless({}, $class); return $this->init(); } sub move { AbstractMethod->throw("Not implemented in this class\n"); } # raise exception unless # implemented by a subclass package BasicTrack; use base Track; sub init { my ($this) = @_; # Add anonymous subroutines to the hash of possible combinations # of status and location. I.e., if the status is 'pending # approval' while the document is sitting in the workspace of a # supervisor, and 'forward' is the command issued to Track::move, # then the subroutine ought to set the status to 'approved', # change group to 'editors'. Other subclasses can inherit # or override these as necessary, to avoid duplication of behavior. $Track::switch{case1} = sub { # do the stuff }; } sub move { my ($this, $arg) = @_; # complicated set of switch statements to figure # out which subroutine in %Track::switch to call. # This would be called from Ticket::move most likely. }