Perl實現新增內容統計

來源:互聯網
上載者:User

標籤:

#! /usr/bin/perluse strict;use utf8;binmode(STDIN,":encoding(utf8)");binmode(STDERR,":encoding(utf8)");binmode(STDOUT,":encoding(utf8)");&extend("/home/hqh/案頭/2",1,",","/home/hqh/案頭/1",1,",","/home/hqh/案頭/result");sub extend{    my($infile1,$col1,$sep1,$infile2,$col2,$sep2,$outfile)=@_;
  #infile1和infile2為比較的兩個檔案,infile1第$col1列和infile2的第$col2列進行比較,輸出到outfile中 open HD1,$infile1; binmode(HD1,"encoding(utf8)"); my @data1=<HD1>; close HD1; open HD2,$infile2; binmode(HD2,"encoding(utf8)"); my @data2=<HD2>; close HD2; open FD,">$outfile"; binmode(FD,":encoding(utf8)"); my %h; foreach(@data1){ chomp($_); my @temp=split($sep1,$_); $h{$temp[$col1]}=1 } foreach(@data2){ chomp($_); my @temp=split($sep2,$_); if(!exists($h{$temp[$col2]})){ print FD $temp[$col2],"\n"; } } close FD; }

 

Perl實現新增內容統計

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.