The technical term for
Thilosophy's solution is a
hash slice. It's important to know how these thingies work, precisely for your kind of issue. I asked a question about this a while ago that generated some discussion about this feature of perl:
Is this a hash slice? if you want some additional back and forth to look at.