open SEARCH, "<$kwords" or die "can't open $kwords $!\n"; { local $/=undef; $_ = ; my @arr = split /()/; shift @arr; # 1st element stuff before , so shift away my %hash = @arr; print map {($_, $hash{$_})} grep { $hash{$_} =~ $word } keys %hash; } close SEARCH;