From: "Berger, Daniel" Date: 2003-12-16T06:53:05+09:00 Subject: Re: Extracting multiple lines from a file > -----Original Message----- > From: Ron Coutts [mailto:rcoutts@envistatech.com] > Sent: Monday, December 15, 2003 2:14 PM > To: ruby-talk ML > Subject: Extracting multiple lines from a file > > > This should be an easy question for Ruby-heads but I can't > seem to easily find the answer. I need to extract multiple > lines from a file where the lines are delimited by some other > text. For example, with file contents as shown below I'd > like to extract the content between the BEGIN_FOO and END_FOO > lines. Can anyone tell me how to do that? > > BEGIN_FOO > Some foo stuff here. > More foo stuff. > END_FOO > > I've done this before in Perl (can't remember the syntax) so > I'm thinking it should be possible in Ruby. > > Ron See the second argument to IO#readlines. Or, you can set $/ manually - same as Perl. :) Regards, Dan