From: Kent Dahl Date: 2003-07-24T07:49:28+09:00 Subject: Re: "regex literal in condition" Daniel Carrera wrote: > # My code > while gets. > break if (/\<\!-{19} ending left_colum -{11}\>/) > end > > # Output: > warning: regex literal in condition > > What is a "regex literal"? How is that different from any other regex? > I just want to read a text file and skip all the lines until I arrive at > the one matching the expression above. A literal is something written directly into the source. "hi" = String literal /hi/ = Regexp literal Regexp.new( "hi" ) = String literal passed to Regexp constructor Ruby does some freaky stuff in some cases, such as when you have a literal in an if, the exact usage you are looking for: an implicit match. Notice how if you do re = /\<\!-{19} ending left_colum -{11}\>/ while gets break if re end then "gets" is only called once because any object instance turns true in a boolean condition. My money is on Matz wanting to deprecate the implicit matching in the future and this is your very early and literal warning. HTH -- (\[ Kent Dahl ]/)_ _~_ _____[ http://www.pvv.org/~kentda/ ]_____/~ ))\_student_/(( \__d L b__/ (pre-) Master of Science in Technology ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)