|There's more than one way to do things|
Re^5: Hashes of Hashes of Arrays? Is it possible?by Marshall (Canon)
|on Sep 08, 2011 at 23:17 UTC||Need Help??|
So as I understand it, you want to dump the current results and start a new %HOH when the $key changes.
When setting something like this up there are 3 things to consider:
One approach for is to dump the results and reset %HOH when the $key changes. To do that perhaps:
To solve question (2), the first time through the loop, I don't dump the %HoH unless there is data there - there is more than one possible way to test for this (keys %HOH) or ($prev_key ne "" ). If the thing that does the dump/final processing of this time slice has some code to not do anything if there is no data, there is no nested "if".
To solve question (3), after the loop ends due to lack of data, dump the final incarnation of the hash.
There is of course more than one way to accomplish what you need, but the 3 questions are always the same : (1)steady-state operation, (2)getting started, (3)getting finished.
I recommend writing the "steady-state", question (1) code first and then "fiddle with it" until questions (2) and (3) work out ok.