while (my $row = $csv->getline($FH)) { my %currentRow; @currentRow{@keys} = @$row; print "Current row: ", Dumper \%currentRow; my $uniqueKey = "$currentRow{Amount} & $currentRow{AmountId} & $currentRow{MRP}"; # Bad idea if '&' is allowed in either of those values push @{ $result{$uniqueKey} }, \%currentRow; # add the current row to the existing ones } print "Result: ", Dumper \%result;