This is my first try:
puts $<.read.split(/\W/).map{|x|x==""||nil 
?"":"#{x[0..0]}#{x[1...a=x.size-1].split(//).sort{rand}}#{x[a..a+1]} 
"}*""

but this doesn't work on single letter words & I wanted to use inject.
My final version:

puts 
$<.inject([]){|a,w|a<<w.gsub(/\B(\w+)\B/){$1.split('').sort_by{rand}}}


j`ey
http://www.eachmapinject.com



-- 
Posted via http://www.ruby-forum.com/.