From: Carl Mueller Date: 2001-05-30T03:11:25+09:00 Subject: [ruby-talk:15949] Perl 6 idea: automatic chomp I was reading over some material about Perl 6: http://www.perl.com/pub/2001/05/08/exegesis2.html It seems that Perl 6 will be much better, and more like Ruby. Among other things, there will be a command to automatically chomp input. Here is my attempt to modify Ruby in the same way. Since I'm a relative newbie, I'd welcome suggestions. # Automatically chomp with "readlines", "readline", or "each". class IO alias old_readlines readlines private :old_readlines def readlines (*input) old_readlines(*input).collect{|line| line.chomp} end alias old_readline readline private :old_readline def readline (*input) old_readline(*input).chomp end alias old_each each private :old_each def each(*vars) if vars.length == 0 old_each { |line| yield(line.chomp) } else old_each(*vars) { |line| yield(line) } end end end ****************** Carl Mueller