hi all,
I have 2 files, and i want to merge based on the column which is common to both the files. here are my input files:
file1:
TST_01 sp|123|fts
TST_02 sp|3438|rvs
TST_03 sp|2744|rtp
file2:
file1:
sp|123|fts checked_proved
sp|3438|rvs proven_right
sp|2744|rtp un_proved
desired result file:
TST_01 sp|123|fts checked_proved
TST_02 sp|3438|rvs proven_right
TST_03 sp|2744|rtp un_proved
#!/usr/bin/perl
open(FH1,file1.txt);
open(FH2,file2.txt);
@array=<FH2>;
while($var=<FH1>){
($first,$second)=split("\t",$var);
@grepped= grep ("$second",@array);
print "$first\t@grepped\n";
}
can any one help? thank you.