From: Bill Kelly Date: 2003-09-13T02:35:43+09:00 Subject: Ruby $_ one-liners (was: Re: Global object instance?) Hi, From: "Ben Giddings" [...] > There are many useful kernel methods that should > stick around. I much prefer using puts to $stdout.puts(), but I > *really* think the String stuff that works on $_ should go. Any thoughts? I strongly disagree. Removing these would mean I'd have to keep my Perl skills honed, which is something I've been glad to be able to let fade away... :) Here are two Ruby one-liners I used just yesterday: ruby -i -pe 'gsub(/#!\\Perl\\bin\\perl.exe/, "#!/usr/bin/perl")' *.cgi ruby -i -pe 'gsub(/\015/, "")' *.cgi *.html *.pm *.txt Something I love about Ruby is that, in addition to everything else it does well, it still lets me write powerful simple one- liners from the command line. (The one-liners above presumably need no explanation, but the context was we were installing a package containing a lot of Perl CGI scripts that had been developed on Windows, and they needed some conversion--line endings, shebang line--in order to work on Linux..... I.e. the point is not that there's anything special about these _specific_ one-liners... Just that it's so easy to craft them in Ruby... If it weren't, I'd have to go back to using Perl for such things... And I wouldn't like that...) Regards, Bill