in reply to 'group by query' from array of hashes

The tricky part is that the hash's key is variable. You need to not only extract the value, but the key. Once you do that, simply build the desired HoA.

my %grouped; for (@queries) { my ($k,$v) = %$_; push @{ $grouped{$k} }, $v; }

The array will automatically get vivified by the lvalue «@{ }» as if you did «$grouped{$k} //= [];», saving you the trouble.