in reply to building an HoAoH ... very badly

Here's one way. I am assuming that within a given season the episodes are returned in ascending order. Since this is from a database query, if that isn't true now, just modify the SQL to make it true. First I build a HoAoH indexed by season number.
my %temp_hash; while (my $ref = $sth->fetchrow_hashref) { my $season = $ref->{season}; my $title = $ref->{title}; push @{$temp_hash{$season}}, { title => $title }; }
Then I build it out.
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.