$queryFile = $ARGV[0]; $queryJoinFieldNum = $ARGV[1] - 1; $dbFile = $ARGV[2]; $dbJoinFieldNum = $ARGV[3] - 1; %dict = (); open RH, $dbFile or die "Could not open $dbFile\n"; while(<RH>){ chomp; $ln = $_; @fields = split(/\t/, $ln); $dbid = $fields[$dbJoinFieldNum]; $dict{$dbid} = $ln; } close RH; open RH, $queryFile or die "Could not open $queryFile\n"; while(<RH>){ chomp ; $ln = $_; @fields = split(/\t/, $ln); $qid = $fields[$queryJoinFieldNum]; print $ln . "\t" . $dict{$qid}. "\n"; } close RH;