本帖最后由 CrLf 于 2014-7-11 15:41 编辑
js 的 eval 有点危险吧
第一感觉是用 vbs,先来个 vbs 版的:- On Error Resume Next
-
- Dim fso,str,i,ar(65536)
-
- i=0
-
- Set fso = WScript.CreateObject("Scripting.Filesystemobject")
- Set ts = fso.OpenTextFile("dd.txt")
- Set ts2 = fso.CreateTextFile("dd_output.txt",true)
-
- Do Until ts.AtEndOfStream
- str = ts.ReadLine
- If InStr("12","/0")=0 Then
- If Eval(str) Then
- ar(i)=str
- i = i + 1
- If i=65536 Then
- ts2.WriteLine Join(ar,vbCrLf)
- i = 0
- End If
- End If
- End If
- Loop
-
- If i>0 Then
- For j=0 To i
- ts2.WriteLine ar(j)
- Next
- End If
复制代码 虽然有为速度稍作优化,但速度还是慢得不可忍受...
再来个 perl 版的,快多了:- open(IN,"dd.txt");
- open(OUT,">dd_output.txt");
-
- while ($str=<IN>){
- next if $str =~ /\/0/;
- $str=~ s/=/==/;
- if(eval($str)){print OUT ($str);}
- }
复制代码
|