Hi Two files, if the first line and the first column are the same, print this line, the second line, the third line,the fourth line. What's wrong with me?
Thanks in advance!01.txt >SR1.2 >SR1.3 02.txt >SR1.1 HWI-ST ATGCTGCT TCGTCGAT CTGATCAGCTAC >SR1.2 HWI-ST0 TTTTGCTGCT TCGTTGGG CTTTATCAGCTAC >SR1.3 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC result >SR1.2 HWI-ST0 TTTTGCTGCT TCGTTGGG CTTTATCAGCTAC >SR1.3 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC #!/usr/bin/perl -w use strict; open(IN1,"01.txt") || die "Cannot open this file"; my @lines1 = <IN1>; open(IN2,"02.txt") || die "Cannot open this file"; my @lines2 = <IN2>; my $i=0; open(OUT,">out01") || die "Cannot open this file"; for my $item1(@lines1){ chomp $item1; my@tmp1=split(/\s+/, $item1); for my $item2(@lines2){ chomp $item2; my @tmp2=split(/\s+/, $item2); if ($tmp1[0] eq $tmp2[0]){ print OUT $lines2[$i],"\n",$lines2[$i+1],$line +s2[$i+2],$lines2[$i+3]; last; } $i++; } print OUT "\n"; } close(IN1); close(IN2); close(OUT);
In reply to Two files, if the first line and the first column are the same, print this line, the second line, the third line,the fourth line. by yueli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |