On Fri, May 04, 2001 at 08:11:24AM +0900, Phil Tomson wrote:
> 
>          srchStr = "/Error/"  
  :
>            if eval srchStr

This construct will not work as expected, it will always go into the
'true'-branch. The eval will result in an object of class Regexp. And
since all objects beside nil and false are true in ruby, this object
will be true too.

You have to match explicitly against $_. A regular expression will
only be matched automatically against $_ if ruby finds is literally in
an 'if'. The following code

  re_str = "/foo/"
  re     = /foo/

  $_ = "biz bar"

  if /foo/       then puts "found, pure RE";        end
  if re          then puts "found, RE in variable"; end
  if eval re_str then puts "found, eval";           end


  if $_ =~ /foo/         then puts "found, explicit match, pure RE";        end
  if $_ =~ re            then puts "found, explicit match, RE in variable"; end
  if $_ =~ (eval re_str) then puts "found, explicit match, eval";           end

produces this output:

  found, RE in variable
  found, eval

So the two false positives come from regular expressions that are not
matched against $_.


This doesn't solve your original problem though. It just makes the
example almost complete nonsense. Everything done there is reading the
whole file line by line and setting (failed,found = false, true) while
processing each line, regardless of the content. Then i is incremented
and everything is done again and again and again....

I have no clue what resources are hogged by this, but if you explain a
little bit more what you want to do here, we might help you to find a
more natural ruby approach to it.

-- 
marko schulz

                          Dieser Satz beinhalten drei Fehller.