From: Simon Schuster Date: 2007-09-07T13:00:02+09:00 Subject: Re: help me condence my code? my local copy has some extra (probably important) authorship/proj gutenberg info at the beginning and end that I've stripped, but other than that this code works perfectly. I really like how it's split up by lines per method. thanks a lot! also is \[ a literal bracket, or some kind of grouping device that just happens to be also the boundary-character I'm looking for? On 9/6/07, Bil Kleb wrote: > Simon Schuster wrote: > > I know this could be more idiomatic to ruby. > > Don't know about idiomatic, but here's my > filter-split-filter take: > > require 'open-uri' > > f = open('http://www.gutenberg.org/files/18362/18362.txt').read. > gsub(/\s*\[.*?\]/m,''). # strip comments > split("\r\n"). # DOS line endings > delete_if{ |e| e.empty? } # remove blank lines > > puts f[ rand f.size ] > > Regards, > -- > Bil Kleb > http://nasarb.rubyforge.org > >