my %function = ( post => \&post, read => \&read, default => \&default ); my $action = get_action(); $action = 'default' unless ( exists $function{$action} ); $function{$action}->( @arg_list );