$VAR1 = [ { 'amount' => '58.80', 'quantity' => '1', 'product_listid' => '800000FA-1450218051', 'id' => '3938716373870073', 'customer_listid' => '8000024C-1450196328', 'datetime' => '1309966331' }, { 'amount' => '1.34', 'quantity' => '1', 'product_listid' => '800000FC-1450218057', 'id' => '3938716373870073', 'customer_listid' => '8000024C-1450196328', 'datetime' => '1309966331' }, { 'amount' => '2.14', 'quantity' => '1', 'product_listid' => '8000010C-1450218105', 'id' => '2446438717782054', 'customer_listid' => '80000245-1450196318', 'datetime' => '1310146917' }, { 'amount' => '1.34', 'quantity' => '1', 'product_listid' => '800000FC-1450218057', 'id' => '2446438717782054', 'customer_listid' => '80000245-1450196318', 'datetime' => '1310146917' } ]; #### [ $id1 => [ { $hashrefs_with_id1 } ... ] $id2 => [ { $hashrefs_with_id2 } ... ] ] #### $VAR1 = { '2446438717782054' => { 'amount' => '1.34', 'quantity' => '1', 'product_listid' => '800000FC-1450218057', 'customer_listid' => '80000245-1450196318', 'datetime' => '1310146917' }, '3938716373870073' => { 'amount' => '1.34', 'quantity' => '1', 'product_listid' => '800000FC-1450218057', 'customer_listid' => '8000024C-1450196328', 'datetime' => '1309966331' } }; #### 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);