From: Jay Levitt Date: 2007-09-28T02:05:06+09:00 Subject: Re: Detecting number ranges On Wed, 26 Sep 2007 14:57:04 -0700, William James wrote: > I'm not in the mood for hash. > > ary = DATA.readlines > ary.map{|s| s[/\d+$/] }.uniq.each{|server| > db = ary.grep(/ #{server}$/).map{|s| > s[/\d+/].to_i}.sort > puts "Server #{server} databases #{db[0]} to #{db[-1]}" > } Definitely wins the "shortest" prize! But, um, no output: #=> Server databases to Looks like .each is called only once, with |server| == nil. Weirder, when I just run: ary = open("fake_data").readlines ary.map{|s| s[/\d+$/] }.inspect return I get: #=> wjames.rb:4: unexpected return (LocalJumpError) I would have thought that ary.map{|s| s[/d+$] } should return an array itself. Although I'm not clear what that line does - doesn't it look for a 1+ digit number n, and return the nth character of the line? -- Jay Levitt | Boston, MA | My character doesn't like it when they Faster: jay at jay dot fm | cry or shout or hit. http://www.jay.fm | - Kristoffer