in reply to merge files by column (revisted)

The Unix way to do it would be to use join. The commands cut and paste might also be helpful here. Note that the 'merge' operation you are performing is equivalent to a relational join.

Another possibility it to try to use the DBD::CSV module (via DBI). Then you can perform the join using a SQL select statement ala

SELECT file1.*, file2.array, file2.value FROM file1, file2 WHERE file1.chr = file2.chr and file1.coord = file2.coord;

With either the Unix join approach or the SQL approach you'll have to decide what happens when file2 doesn't contain a row corresponding to file1 and vice-versa.

Replies are listed 'Best First'.
Re^2: merge files by column (revisted)
by Anonymous Monk on Oct 05, 2011 at 22:24 UTC
    "you'll have to decide what happens when file2 doesn't contain a row corresponding to file1 and vice-versa. " That has pointed out the very common issue when you merge two or more files. Do you have any clue?