On Sat, May 05, 2001 at 08:41:24AM +0900, Phil Tomson wrote: > i = 0 > failed = true > found = false > while true do > i += 1 > puts i > rptFile = "CYPsw00695.rpt" > srchStr = "!(/Error Count = [1-9]/ || /Abort/ || /[1-9] error/ || > /fatal/)" > rpt_h = File.open rptFile > puts "after File.open #{rptFile}" if $DEBUG > puts "srchStr is: #{srchStr}" if $DEBUG > while rpt_h.gets do > #puts "while: #$_" if $DEBUG > > if eval srchStr > failed = false > found = true > #puts "FOUND: #$_" if $DEBUG > else > failed = true > puts "FAILED : #$_" if $DEBUG > break > end #if eval > GC.start #<=== this solved the problem > end > rpt_h.close > end > > ####################################################### > > Apparently, the regex's in the srchStr create regex objects during the > eval and those regex objects take a while to get cleared out by garbage > collection and since there are many thousands of lines in the file being > checked, the eval happens thousands of times (once on each line). It may > be that on a larger file, I may need to do the GC.start after some number > of lines in order to avoid running out of space. Wouldn't it be easier to compile the regular expression once before you opent the file, then use the object's 'match' method at each line? srch_pat = Regex.compile("!(/Error Count = [1-9]/ || /Abort/ || /[1-9] error/ || > /fatal/)") ... while (line = rpt_h.gets) do if srch_pat(line) failed = false ... David S. > > Phil