网上的题
文件a.txt
|
1
2
3
4
|
ATCGTCGAGTCGAGTCGTAGCTCGATGCTAACTCAACGATCGATCAGCAT |
文件 b.txt
|
1
2
3
4
|
23 4534 7634 6737 78 |
请输出文件
|
1
2
3
4
|
ATCGTCGAGTCGA 23 45GTCGTAGCT 34 76CGATGCTAACTCAA 34 67CGATCGATCAGCAT 37 78 |
直接上代码
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/perl -wuse strict;
my (@array1,@array2);
open my $file,'<','a.txt' or die "$!\n";
while (<$file>) {
chomp;
next if /^$|^#/;
push @array1,"$_\t" if $_;
}open $file,'<','b.txt' or die "$!\n";
while (<$file>) {
chomp;
next if /^$|^#/;
push @array2,"$_" if $_;
}for my $str (@array1) {
$str .= shift @array2;
print $str,"\n"
} |
输出
|
1
2
3
4
5
|
[[email protected] home]# perl a.pl
ATCGTCGAGTCGA 23 45GTCGTAGCT 34 76CGATGCTAACTCAA 34 67CGATCGATCAGCAT 37 78 |
代码图片
本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/1535563,如需转载请自行联系原作者