in reply to Dispatching Method Objects

Use coderefs:
my %dispatch = ('a'=>\&first, 'b'=>\&second); sub dispatch { my $self = shift; my $command = shift; $dispatch{$command}->($self, @_); }
Note this removes the OO'ness of it, i.e. no inheritance.
Update:Realized this and was updating just as tilly was replying :)

Possibly another option is to prod Damian into finishing Class::Delegation :-)

Replies are listed 'Best First'.
Re (tilly) 2: Dispatching Method Objects
by tilly (Archbishop) on Oct 03, 2001 at 21:26 UTC
    Whether or not to use code refs depends on what you are doing. If you use code refs your dispatch will ignore inheritance. If you the dynamic method lookup that I posted, your dispatch will allow subclasses to usefully override the method that you are dispatching to.