my @v1=qw(horse hearse house hose); my @v2=qw(fax fix fox flux); my @v3=qw(orange lemon melon plum apple banana rama); my $regex = join("|",@v1,@v2,@v3); sub one { print "Begins with an h\n"; } sub two { print "Oh those Xes\n"; } sub three { print "Yummy!\n"; } my %table; @table{@v1,@v2,@v3}=((\&one)x scalar(@v1), (\&two)x scalar(@v2), (\&three)x scalar(@v3)); if (my ($match) = $input =~ m/($regex)/) { &{$table{$match}}; }