List::GroupBy is a small module that converst a list of hash referenes to a multilevel hash of hashrefs of arrayrefs. If this is too much, check out the example in the Synopsis.
minla test
HARNESS_PERL_SWITCHES=-MDevel::Cover prove -l
git clean -fdx