On Thu, 26 Apr 2001, Phil Tomson wrote: > $expression = "!(/Error/ || /Abort/ || /[1-9] error/ || /fatal/)" > #actually $expression was read from one of many (thousands) of files > open(RPT,"reportfile) or die ; ^ you forgot the closing " :-) > while (<RPT>) { > if(eval "$expression") { > $found = 1; > #other stuff.... > } > } > > So 'eval "$expression"' returns a true value if $expression evaluates to > true (in the Perl sense of truth). > > Now, I'm finding that something like: > > if (line =~ !(/Error/ || /Abort/ || /[1-9] error/ || /fatal/) ) > > just isn't going to work in Ruby for various reasons. Technically, the > strings in $expression (above) are not regular expressions, they are > formulas that contain regular expressions. You can use $_, which IO#gets will assign to automatically: expression = "!(/Error/ || /Abort/ || /[1-9] error/ || /fatal/)" fh = File.open "phil.dat" # see below while fh.gets do puts $_ unless eval expression # or whatever end phil.dat: This line contains Abort. This one doesn't. This one says Error. Output: This line contains Abort. This one says Error. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav