- 论坛徽章:
- 2
|
各位大侠,
如果第一行第一列相同,打印第一行,第二行,第三行,第四行。
01.txt
>SR1.2
02.txt
>SR1.1 HWI-ST
ATGCTGCT
TCGTCGAT
CTGATCAGCTAC
>SR1.2 HWI-ST0
TTTTGCTGCT
TCGTTGGG
CTTTATCAGCTAC
>SR1.3 HWI-ST0787
GGGGGCTGCT
AATCGTCGAT
AACTGATCAGCTAC
结果:
>SR1.2 HWI-ST0
TTTTGCTGCT
TCGTTGGG
CTTTATCAGCTAC
自己遍的程序,错在哪里?
open(IN1,"01.txt") || die "Cannot open this file";
@lines1 = <IN1>;
open(IN2,"02.txt") || die "Cannot open this file";
@lines2 = <IN2>;
open(OUT,">out01") || die "Cannot open this file";
for $item1(@lines1){
chomp $item1;
#print OUT $item1,"\t";
@tmp1=split(/\s+/, $item1);
for $item2(@lines2){
chomp $item2;
@tmp2=split(/\s+/, $item2);
if ($tmp1[0] eq $tmp2[0]){
print OUT $lines2[$i],"\n",$lines2[$i+1],$lines2[$i+2],$lines2[$i+3];
last;
}
$i++
}
print OUT "\n";
}
close(IN1);
close(IN2);
close(OUT);
先谢谢了! |
|