in reply to Mysterious hash problem

I'm not sure how your input file is generated/populated, but it might be worth thinking about doing more than chomp in your foreach loop - such as dealing with leading/trailing whitespaces and capitalization. Consider the the following quoted strings and if they all should be counted under the same key in your hash:

If you trust that the input file won't have such variations, then it might not cause you issues if you decide to not add some code to handle those situations.

Another thing to consider is that using %dict and $dict might lead to some confusion for yourself later. The same could happen with using $wd and $wds.

Just sharing the thoughts that popped into my mind when looking over your code. Not saying that any of the above is necessarily "wrong", but those are the types of things that have gotten me into trouble with my code.