my %actions = ( this => \&this, that => \&that, foo => \&foo, bar => \&bar, zzz => \&sleepytime, ); # ooh, tricky foreach (@user_actions) { if (defined(my $sub_ref = $actions{$_})) { $sub_ref->(); } }