From: Ashley Moran Date: 2006-04-28T07:56:28+09:00 Subject: Re: getting the next line with the iterator On Apr 27, 2006, at 11:20 pm, Eric Boucher wrote: > I would like to know if there is a ruby way to achieve what I want to > do. I want to be able to access the next iterator while reading a > file. > Basically, I want to be able to collect the next 3 lines when I > encounter a certain line Eric How bout this? list = [] File.open('testdata.txt') do |file| start_line = -1 file.each do |line| start_line = $. if line =~ /start_here/ list << line if ($. == start_line + 1) .. ($. == start_line + 3) end end Ashley