[問題] 兩個檔案比對問題

看板Perl作者 (TEST123)時間14年前 (2011/02/09 15:26), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
想請教一個問題 我想比對兩個檔案的內容 利用兩個迴圈去讀兩個檔案 邊讀邊丟到串列 然後做比對 可是卻只做一次比對就結束了 這讓我困擾很久 感謝回答的先進謝謝 我的程式碼如下 use strict; open(FileHandle, "<1missdo.txt") or die "can't open 1missdo.txt\n"; open(FileHandle1, "<9901.txt") or die "can't open 9901.txt\n"; open(output_1, ">0127output".".txt") or die "can't open 0127output\n"; while (my $line = <FileHandle>){ my @items = split (/ /,$line); while (my $line1 = <FileHandle1>){ my @items1 = split (/ /,$line1); if($items[2] =~ /$items1[3]/g){ print output_1 "$items[0] $items[1] $items[2] $items[3]\n"; print output_1 "$items1[7] $items1[22] $items1[3] $items1[17]\n"; }#end of if($items[2] =~ /$items1[3]/g){ }#end of while (my $line = <FileHandle>){ }#end of while (my $line1 = <FileHandle1>){ close(FileHandle); close(FileHandle1); close(output_1); -- -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.126.31.119

02/09 17:00, , 1F
大老 排個版吧
02/09 17:00, 1F
排版好了 ※ 編輯: piglon 來自: 59.126.31.119 (02/09 17:06)
文章代碼(AID): #1DKa6HYs (Perl)
討論串 (同標題文章)
文章代碼(AID): #1DKa6HYs (Perl)