From: "Kurt M. Dresner" Date: 2003-09-17T03:33:23+09:00 Subject: Re: scrambler one-liner Try -pe 'gsub!(/\B\w+\B/){$&.split(//).sort_by{rand}.join} Shorter (and even cleaner too!) -Kurt On Wed, Sep 17, 2003 at 03:20:53AM +0900, Xavier Noria wrote: > On Tuesday 16 September 2003 20:07, Kurt M. Dresner wrote: > > > This is hilarious, because a friend and I just had (over lunch) a > > race to see who could code it up first. I used Ruby and he used > > Perl. Mine worked first, but then I reworked it a bit to make it > > neater. His was impossible to read, but I totally have to send him > > this one-liner. Man, sort_by{rand} is so awesome! I can't believe I > > didn't think of that! > > Cool! :-) I have just written this version even shorter: > > -pe 'gsub!(/(\w)(\w+)(?=\w)/){$1+$2.split(//).sort_by{rand}.to_s}' > > -- fxn > > >======= End of Original Message =======<