网上的题
文件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