网上的题
文件a.txt
ATCGTCGAGTCGA GTCGTAGCT CGATGCTAACTCAA CGATCGATCAGCAT
文件 b.txt
23 45 34 76 34 67 37 78
请输出文件
ATCGTCGAGTCGA 23 45 GTCGTAGCT 34 76 CGATGCTAACTCAA 34 67 CGATCGATCAGCAT 37 78
直接上代码
#!/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"
}输出
[root@lb-01 home]# perl a.pl ATCGTCGAGTCGA 23 45 GTCGTAGCT 34 76 CGATGCTAACTCAA 34 67 CGATCGATCAGCAT 37 78
代码图片
本文出自 “BSDerの-专注于开源领域” 博客,请务必保留此出处http://hellosa.blog.51cto.com/2698675/1535563
原文:http://hellosa.blog.51cto.com/2698675/1535563