in reply to Dispatching Method Objects
(You can add error checks, etc.)sub dispatch { my $self = shift; my $meth = { a=>"first", b=>"second" }->{shift(@_)}; $self->$meth(); }
BTW if you can, it makes more sense to drop your dispatch all together and let client code look for the methods by name. And then you can put error checks in an AUTOLOAD.
|
|---|