in reply to Order a hash?

The answers above are probably enough to solve your problem, but just for reference, there's always the Tie::IxHash module. It provides hashes that preserve the order in which the elements were added. The elements can also be ordered in other ways. Look up the documentation for Tie::IxHash for a better explanation of all it's features.