sub createHoAoHfromAoHbyIndexingByTheValueOfOneKey{ my( $AoHref, $key ) = @_; ### About 20 lines of parameter checking and error reporting/exception ### handling here. Because unlike doing it in-line, the programmer writing ### this function cannot know what the caller will pass him. my %HoAoH; push @{ $HoAoH{ delete $_->{ $key } } }, $_ for @$AoHref; return \%HoAoH; }