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

my @all_queries = ( {'foo' => 20}, {'bar' => 30}, {'foo' => 10}, {'zen' => 90}, {'zen' => 1}, ); my %hash; push @{$hash{(keys %$_)[0]}}, (values %$_)[0] foreach (@all_queries); foreach my $key (keys %hash) { print "$key has " . join(',', @{$hash{$key}}) . "\n"; }
- Miller