You need to provide more details on what you're doing and what you need to accomplish, but based on what you've posted I can say that you're using the wrong data structure. Instead of 3 separate hashes, you should be using 1 HoH ( hash of hashes).