|Pathologically Eclectic Rubbish Lister|
building an HoAoH ... very badlyby Cody Pendant (Prior)
|on Jan 10, 2005 at 03:22 UTC||Need Help??|
Cody Pendant has asked for the
wisdom of the Perl Monks concerning the following question:
OK I know this code is hideous, believe me. That's why I'm seeking the wisdom! It's more of a logic problem than simply a Perl problem, but...
I'm getting some data out of SQL (fetchrow_hashref) in the form:
That is, it's a long list of episodes, some in season n, some in season n+1 and so on. I need to put it into a structure like this:
An array of hashes for each season, and each episode an entry in an array within that hash.
Here's how I did it late last night, and it works, but there must be a better way than this:
Where I build little structures and append them onto the big structure by watching for a change of season, with extra clauses for the first time around and so on.
I await your advice. Please be kind.
Update: Forgot to say, yes the data comes out in the right order, that's not part of the problem, and no, it's not an HoAoH, is it? It's an AoHoWhatever.