Tie::Hash::Indexed maintains an ordered hash. Also, use
each only if you're aware of the fact that breaking an iteration partly through the hash means that subsequent iterations will start where it left off. You may be safer with the foreach/keys idiom.
It may be worth mentioning PDL if you're going to be doing math stuffs with complex data structures. But it might be a bit overkill for your application.