From: Thomas E Enebo Date: 2005-02-10T06:05:45+09:00 Subject: Re: How to mimic Perl's `s///' in Ruby? On Thu, 10 Feb 2005, Glenn Parker defenestrated me: > Jos Backus wrote: > >Given Perl's > > > > $_ = "123 foo"; > > > > s/^(\d+)\s+//; > > $pid = $1; > > > > print "$_\n$pid\n"; > > Closer to the original Perl: > > line = "123 foo" > line.sub!(/^(\d+)\s+/, '') > pid = $1 > puts line, pid Even a little closer to the original perl...Though I am sure you are not asking how to get ruby syntax closer to Perls :) alias :s :sub $_ = "123 foo"; s /^(\d+)\s+/, ''; $pid = $1; print "#$_\n#$pid\n"; -Tom -- + http://www.tc.umn.edu/~enebo +---- mailto:enebo@acm.org ----+ | Thomas E Enebo, Protagonist | "A word is worth a thousand | | | pictures" -Bruce Tognazzini |