my %message_types = ( type1 => 'sub_1', type2 => 'sub_2', ); $method = $message_types{$type}; $self->$method(@args);