my %actions = ( Register => \&handle_register, "Book Course"=> \&handle_book_course, # ... ); # ... if (defined $actions{$action}) { $actions{$action}->(); } else { print "No such action $action..."; }