From: Gavin Sinclair Date: 2004-09-16T09:57:45+09:00 Subject: Re: Ex-Perl coders: Howz it feel to convert to Ruby? On Thursday, September 16, 2004, 10:39:02 AM, Joel wrote: >> perl -e 'while (<>) { /"(\w*)"/; print "$1\n" }' file-snippet.txt >> >> In Ruby? I didn't have the time to figure it out. Which is the >> agonizing point. Later, I did the following in Ruby to satisfactory >> effect: >> >> ruby -e 'ARGF.each { |line| line.scan( /"(\w*)"/ ) { |frag| puts frag } >> }' file-snippet.txt >> >> Perhaps someone can refine this while we're at it. It's hard not to >> notice that the Perl was more concise. Perhaps my ignorance can be made >> right...? Can this be shortened in Ruby? Surely... > Golf.shoes = "on" > $ ruby -n -e 'puts $1 if /"(\w+)"/' file-snippet.txt $ ruby -ne 'puts $1 if /"(\w+)"/' file-snippet.txt Easiest game of golf I ever played :) Gavin