From: Dave Thomas Date: 2001-03-24T05:02:13+09:00 Subject: [ruby-talk:13157] Re: Amusing contrast Bob Kline writes: > I was struck by the discrepancy between this quote from the Ruby man > page: > > If you want a language for easy object-oriented program- > ming, or you don't like the Perl ugliness, or you do like > the concept of lisp, but don't like too much parentheses, > Ruby may be the language of your choice. > > and this excerpt from one of the Ruby scripts in the build package for > Ruby itself [1]: > > File.foreach($config || "config.status") do |$_| > next if /^#/ > if /^s%@(\w+)@%(.*)%g/ > name = $1 > val = $2 || "" > next if /^(INSTALL|DEFS|configure_input|srcdir)$/ =~ name > val.gsub!(/\$\{([^{}]+)\}/) { "$(#{$1})" } > CONFIG[name] = val > end > end FWIW, I agree that's an ugly piece of code. So, here's a challenge for anyone who wants to try it. Re-express this code in 12 or fewer lines of Ruby. Make it look 'nice'. Make it more readable. Do it in different styles. And post the results here. Have fun. Dave