in reply to building an HoAoH ... very badly
Then I build it out.my %temp_hash; while (my $ref = $sth->fetchrow_hashref) { my $season = $ref->{season}; my $title = $ref->{title}; push @{$temp_hash{$season}}, { title => $title }; }
my $appearances = [ map { +{ season => $_ , eps => $temp_hash{$_} } } sort keys %temp_hash ];
Update: This solution has one small advantage in that it could work even if the seasons weren't numeric, but I kind of like broquaint's because it skips the intermediate step and also takes advantage of the seasons being ordered, which mine doesn't.
|
|---|