From: Robert Klemme Date: 2004-08-30T20:25:27+09:00 Subject: Re: File read progress "Tim Hunter" schrieb im Newsbeitrag news:PXqYc.548$MO3.87112@twister.southeast.rr.com... > JG wrote: > > > 2) query the filehandle to tell me where I am at with respect to the total > > file size. > > See the pos method in IO. #pos will only help if you know the number of lines beforehand. That's typically not the case. How about this: def read_records(file, rx, report = $stderr) size = File.size file File.open( file ) do |io| rec = [] sum = 0 threshold = 10 while ( line = io.gets ) sum += line.size line.chomp! perc = sum * 100.0 / size if perc > threshold report.printf "Read %.1f%\n", perc threshold += 10 end rec << line if rx =~ line end return rec end end Then you can do records = read_records("foo.bar", /keyword/) # eat the status info: records = read_records("foo.bar", /keyword/, StringIO.new) Kind regards robert