in reply to Use of fetchall_hashref

This isn't a direct answer to your problem, but Darin McBride just wrote a demo for DBD::CSV that also covers the problem of restructuring the hashref result from fetchall_hashref. It is a good, fast read. The relevant part is:
my %totals; for my $r (@$res) { $totals{ $r->{AcNo}}{$r->{Type} } = $r->{SUM}; }