my $sub = 'handle_' . $type; die qq(There is no such type as "$type"\n) unless $self->can ($sub); $self->$sub (); ... sub handle_integer { ... }