From: Dave Thomas Date: 2001-05-05T10:14:32+09:00 Subject: [ruby-talk:14696] Re: bizarre eval resource problem solved "Guy N. Hurst" writes: > >>> > To determine pass/fail, there is a string in the > file (which is the srchStr in the example above) that is an expression > composed of regex's and logical operators, like: > "!(/Error Count = [1-9]/ || /Abort/ || /[1-9] error/ || /fatal/)" > <<< > > > So you see, the string is in the file. Since it is pre-existing, > he can't be told to do it otherwise. This is a legacy code issue ;-) No, but we can suggest he do it differently :) I haven't performance tested this, but it does avoid the eval each time around the loop. It uses the proof-of-concept eregex package distributed with the Ruby source: require "eregex" pat = "/a/ | /b/" matcher = eval "proc {|str| str =~ " + pat + "}" while line = gets if matcher.call line puts line end end Regards Dave