in reply to Re: Fun with words (Golf?)
in thread Fun with words (Golf?)

You have more rigor in your regex than is needed.
perl -MList::Util=shuffle -pe 's:\B\w+\B:join"",shuffle split//,$&:ge'

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: Fun with words (Golf?)
by sauoq (Abbot) on Nov 09, 2005 at 16:23 UTC

    Look Ma, no modules!

    perl -pe's!\B\w+\B!@s=split//,$&;my$s;$s.=splice@s,rand@s,1while@s;$s! +eg'
    Three chars for List::Util is a good trade, I think... :-)

    -sauoq
    "My two cents aren't worth a dime.";
    
      An alternative to split trims two of those chars.
      perl -pe's!\B\w+\B!@s=$&=~/./g;my$s;$s.=splice@s,rand@s,1while@s;$s!eg +'

      Caution: Contents may have been coded under pressure.
        And trim 6 chars off the rival:
        perl -MList::Util=/./ -pe's:\B\w+\B:join"",shuffle $&=~/./g:ge'
        (update: changed this from using split too; thanks Roy_Johnson)
Re^3: Fun with words (Golf?)
by hossman (Prior) on Nov 09, 2005 at 18:11 UTC

    ahh, \B ... I can't remember the last time i had a reason to use that ... nice catch.