兩個檔案拼一個

來源:互聯網
上載者:User

標籤:兩個檔案拼一個 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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.