my %dispatch = ('a'=>\&first, 'b'=>\&second); sub dispatch { my $self = shift; my $command = shift; $dispatch{$command}->($self, @_); }