my %stuff = ( moo => "cow", test => "blue", dark => "black", white => "light", house => "home", "all things" => "multi", money => "value", ); while (my ($k, $v) = each(%stuff)) { if { $input =~ /$k/ } { change = $v; last; # break out of the loop now }