On a more general level (the other Monks have already answered your question), remember that whenever you are working with data-structures such as array of hashes; hash of hashes, ... you can make good use of
Data::Dumper to show you the data in your structures. Many times, errors which would totally stump you become obvious when you look at how the data is actually stored.
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law