- 论坛徽章:
- 0
|
本帖最后由 xiaomm250 于 2014-04-11 18:10 编辑
q1208c 发表于 2014-04-11 17:50
回复 5# xiaomm250
这要看你的文件有多大. 如果只有几行, 当然没问题. 如果有上百万行. 你得多少内存呀 ... - #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);
复制代码 为什么我的这个代码会没用呢?????????? |
|