if ($category_id eq "all") { push @all_matches, SomethingAll(...); } elsif ($category_id eq "subj") { push @all_matches, SomethingSubj(...); } #### my %dispatch_table = ( all => \&SomethingAll subj => \&SomethingSubj _default => \&SomethingDefault ); ... my $callback = $dispatch_table{$category_id} || $dispatch_table{_default}; push @all_matches, $callback->(...);