my %dispatch = ( test1 => \&test1, test2 => \&test2, etc.. ); if(exists $dispatch{$op}) { $dispatch{op}->($arg); } #### if(defined &$op)