my @keys = ('test', 'dark', 'white', 'house', 'all things', 'money', 'country'); my @values = qw(blue black light home multi value USA); my $regex = join '|', @keys; # "map quotemeta" might be needed for uglier keys $regex = qr/($regex)/; my %switch; @switch{@keys} = @values; my $change; if ($item =~ $regex) { $change = $switch{$1}; } else { $change = "neutral"; } print "Final Item = $change.\n";