Hash, unlike if, has no order. If the order matters, you might need something like the following (alternatives in regexes match from the leftmost one):
my @keys
= ('test', 'dark', 'white', 'house', 'all things', 'money', 'count
+ry');
my @values
= qw(blue black light home multi value USA);
my $regex = join '|', @keys; # "map quotemeta" might be needed for ugl
+ier 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";