my @row = $r->hashes; # produce flat format of arrays of hashrefs my %row; for my $row (@row) { push @{$row{$row->{id}}}, $row; } warn Dumper(\%row);