From: Derek Smith Date: 2009-08-18T00:39:06+09:00 Subject: Re: while !file.eof? Robert Klemme wrote: > 2009/8/17 botp : >>> � � � �while !mailog.eof? >> �p line if line =~ /^#{last_record}/ >> end > > You're not closing the file handle properly. :-) > > Better: > > File.foreach "maillog" do |line| > p line if /^#{last_record}/o =~ line > end > > Kind regards > > robert OK thx guys! mailog="/tmp/maillog" last_record="Jul 15 22:09:10" File.open(mailog, 'r+').each { |line| p line if line =~ /^#{last_record}/o } But now, what is the diff between File.open( "maillog" ).each do |line| and File.open("mailog").each { |line| one better, or more ruby standard? I did not see a diff. Personally I like "without the do" as there is less to type. -- Posted via http://www.ruby-forum.com/.