16 Sep 2003 fxn   » (Master)

Trehe is this ietetnrnsig actlire tdaoy at Shlosdat taht eixapnls taht aicdcnorg to smoe Eigslnh uveirnitsy the oredr of lteters in words is not relaly rnlaeevt for rdaieng as long as the fsrit and the lsat are at the rghit place. (It semes taht does not hold in Spisanh).

Trehe is a link to a Perl feitlr that megnus a gvien text taht way and I watned to write a mock-up as a one-lnier, but in Ruby this tmie. Hree it is (but see Updtae 2):

    ruby -pe 'gsub!(/\w+/){|w|r=1..w.size-2;w[r]=w[r].split(//).sort_by{rand}.to_s;w}'

Udpate: And tihs is ahotner one in Perl (but see Utdape 3):

    perl -MList::Util=shuffle -pe 's:(?<=\w)\w+(?=\w):join"",shuffle+split//,$&:ge'    

Updtae 2: And that in Ruby bemoces (but see Update 4):

    ruby -pe 'gsub!(/(\w)(\w+)(?=\w)/){$1+$2.split(//).sort_by{rand}.to_s}'

Utdape 3: Wihch in trun gevis:

   perl -pe 's:\B\w+\B:join"",sort{.5<=>rand}split//,$&:ge'

Update 4: This improvement comes from ruby-talk:

    ruby -pe 'gsub!(/\B\w+\B/){$&.split(//).sort_by{rand}.join}'

Hey what a funny time!

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!