- 論壇徽章:
- 0
|
本帖最后由 xiaomm250 于 2014-04-11 18:10 編輯
q1208c 發(fā)表于 2014-04-11 17:50 ![]()
回復(fù) 5# xiaomm250
這要看你的文件有多大. 如果只有幾行, 當(dāng)然沒問題. 如果有上百萬行. 你得多少內(nèi)存呀 ... - #2.txt有的,但是1.txt卻沒有的,把這些行輸出到3.txt
- open(File1,'<1.txt') or die "can not open file:$!\n";
- open(File2,'<2.txt') or die "can not open file:$!\n";
- open(File3,'>3.txt') or die "can not open file:$!\n";
- foreach $line2(<File2>)
- {
- $k=0;
- foreach $line1(<File1>)
- {
- if ($line2 eq $line1)
- {
- $k=$k+1;
- }
- }
- if ($k==0)
- {
- print File3 $line2;
- }
- }
- close(File1);
- close(File2);
- close(File3);
復(fù)制代碼 為什么我的這個(gè)代碼會(huì)沒用呢?????????? |
|