my %actions = ( 1 => \&error_entry, 2 => \&warning_entry, ); my $action_sub = $actions{$value_to_check} || \&default_action; $action_sub->($args_for_this); #### $object->$method($args_for_this);