From: James Edward Gray II Date: 2007-07-10T09:53:20+09:00 Subject: Re: Beautiful Code : Pity he didn't ask here... On Jul 9, 2007, at 7:15 PM, John Carter wrote: > Well, maybe for the 2nd edition, heres my bash at cleaning it up... > > For example scanning a log file..... > > EXAMPLE 4-2 . Printing article names > 1 ARGF.each_line do |line| > 2 if line =~ %r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/ > [^ .]+) } > 3 puts $1 > 4 end > 5 end > > Since most Linux distro's roll the log files to a reasonable size I > would have just gone with... > > ARGF.read.scan( %r{GET /ongoing/When/\d\d\dx/(\d\d\d\d/\d\d/\d\d/ > [^ .]+) }) do |match| > puts $1 > end Hmm, I don't think we should slurp when we don't need too. There's no reason to be wasteful. I really liked the rest of your fixes though. James Edward Gray II