in reply to map to hash of arrays

Perhaps DBI Recipes has something useful for you.

Check the sections about lists of hashes and hashes of hashes.