On Tue, Jun 24, 2003 at 11:02:58AM +0900, Jim Bob wrote:
> I'm hoping someone can jog my memory here. Say I've got a file which
> contains the keywords "START" and "END", with several lines in between.
> Suppose I want to operate on everything between START and END (inclusive
> or not, doesn't really matter, I don't think).
> 
> Naively, I would do one of a couple things: either use a multiline
> regexp, or read the file until START is encountered, and set some sort
> of "readthis" flag which signals the program to operate on the lines
> until END is encountered, at which point the flag is unset.
> 
> *However*.... I'm pretty sure that, somewhere, sometime, I saw some much
> more elegant way of doing this in ruby. I said "neat!", and promptly
> forgot about it. Something involving ranges, maybe? Anybody have an idea
> what I might have been thinking of, or am I misremembering?

while line = gets
  if line =~ /^START$/ .. /^END$/
    puts line
  end
end

('puts line' will ping all lines between and including the START and END
lines)

Regards,

Brian.