From: come Date: 2007-06-04T16:35:25+09:00 Subject: Re: Ruby problem with conditional ranges Hi, Implicit match against "$_" is not anymore supported in version 1.8. You cas still use it in command line form (with "-e" option). In regular file, you have to write the match explicitly : ## one ## two ## three ## four ## five File.open($0, 'r') { |f| while f.gets print $_.sub(/^##/, '') if ($_ =~ /^## two/) .. ($_ =~ /^## four/) end } On 4 juin, 08:56, "Todd A. Jacobs" wrote: > I'm running into a problem doing a conditional range in ruby. The sample > code is: > > #!/usr/bin/ruby > > ## one > ## two > ## three > ## four > ## five > > File.open($0, 'r') { |f| > while f.gets > print $_.sub(/^##/, '') if /^## two/ .. /^## four/ > end > } > > I'm expecting: > > two > three > four > > but I get the whole file with the leading pound signs stripped off. > What's wrong here? > > -- > "Oh, look: rocks!" > -- Doctor Who, "Destiny of the Daleks"