网上的题
文件a.txt
|
1
2
3
4
|
ATCGTCGAGTCGA
GTCGTAGCT
CGATGCTAACTCAA
CGATCGATCAGCAT
|
文件 b.txt
|
1
2
3
4
|
23 45
34 76
34 67
37 78
|
请输出文件
|
1
2
3
4
|
ATCGTCGAGTCGA 23 45
GTCGTAGCT 34 76
CGATGCTAACTCAA 34 67
CGATCGATCAGCAT 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 -w
use
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
|
[root@lb-01 home]
# perl a.pl
ATCGTCGAGTCGA 23 45
GTCGTAGCT 34 76
CGATGCTAACTCAA 34 67
CGATCGATCAGCAT 37 78
|
代码图片
本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/1535563,如需转载请自行联系原作者
