in reply to How to combine multiple files together

To start I would concatenate all the CSV-files together (which can only be done if they all have the same fields in the same order), then with the help of a module like Text::CSV_XS extract the value of the key field for every record from this CSV-file and save these in a hash (so you have only unique keys and no duplicates).

Next open the big CSV-file again with DBD::CSV and using an SQL statement such as "SELECT * FROM big.csv WHERE keyfield = key_value" replacing key_value by the keys in your hash, you extract the records one by one based upon the value of the keys.

As soon as you extract a record you write it to disk with Text::CSV_XS in another file.

If your csv-files are not too big, you could also try to read each record in each file with Text::CSV_XS and build a hash of arrays keyed by the value of your key-field and then empty the HoA back into a final CSV-file. This is probably faster but less intuitive.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law