標籤:兩個檔案拼一個 perl
網上的題
檔案a.txt
ATCGTCGAGTCGAGTCGTAGCTCGATGCTAACTCAACGATCGATCAGCAT
檔案 b.txt
2345347634673778
請輸出檔案
ATCGTCGAGTCGA2345GTCGTAGCT3476CGATGCTAACTCAA3467CGATCGATCAGCAT3778
直接上代碼
#!/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"}
輸出
[[email protected] home]# perl a.plATCGTCGAGTCGA 23 45GTCGTAGCT 34 76CGATGCTAACTCAA 34 67CGATCGATCAGCAT 37 78
代碼圖片
650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/44/1B/wKiom1PfPD_wZ2I1AAFulh9_G3M689.jpg" title="1.png" alt="wKiom1PfPD_wZ2I1AAFulh9_G3M689.jpg" />
本文出自 “BSDerの-專註於開源領域” 部落格,請務必保留此出處http://hellosa.blog.51cto.com/2698675/1535563