So when you run the first loop, with a reference to a non-empty array of keywords to search for, it works fine and you don't see any evidence of a bogus entry in the "%locations" hash. Then, when you do a second loop, with a reference to an empty array instead of a keyword list, you see the extra "$article" key that turns out to be an empty string instead of a hash ref.
Since it looks to me like the "process_article" sub is not changing anything in %locations, the next question would be: what happens between these two loops? Also, when you say that you print out all the keys in %locations "to make sure they're all there and they are", you should be looking for a key that is an empty string. To make this visible, you'd need to do something like:
(If your keys include colon characters, use something else as a separator, e.g. "|".) If this print-out shows two separators in a row, you're looking at a hash element with an empty string as the hash key. In that case, you need to figure out where (and how many times) you are using an empty string to set or inspect an element of this hash array, before going into that second loop.print ":",join(":", keys %locations),":\n";
It may also be possible, the way the "process_article" logic is written, that you would only notice an empty string for $article when you happen to be doing a "chromosome search"; i.e. the empty hash key is there in both loops, and only causes trouble in the second one. But I'm just guessing about that.
In reply to Re: Re: Re: Problem with a hash of hashes
by graff
in thread Problem with a hash of hashes
by dannoura
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |