|Don't ask to ask, just ask|
Re: array of hashes?by marinersk (Chaplain)
|on Oct 27, 2013 at 14:31 UTC||Need Help??|
However, your question doesn't seem to match the title; or at least, I'm slow enough without my first cup of coffee this morning that I don't see how you're heading anywhere near an Array of Hashes (hereafter, AoH) with your problem.
Therefore, at the end of this post, I will give you a working example of an AoH in hopes that this will bridge the gap. Absent that, the conversation will hopefully lead us in a useful direction.
What your last paragraph and code suggest is that you are heading toward continued use of your hash as it exists, merely changing the keys based on a switch.
The purpose of an array is to have a list (no pun intended) of items which are simply stacked up and conveniently accessed. Traditionally accessed via their index value ( through [n]), Perl stepped up and gave us an indexless way to work through the queue in its most common use case: Sequentially processing each element. Perl's genius addition was the foreach loop.
So an Array of Hashes is a way to stack up a bunch of hashes in one place so they can be accessed without particular attention to how many of them there are, where they can later be processed (likely in a foreach loop).
I am really not making the connection between your description and the need to track multiple hashes from a single point.
Can you clarify? Or is it possible that AoH isn't exactly what you were looking for?
In the meantime, here's a sample use of AoH: