in reply to Fun with words (Golf?)
The following uses pretty much the original code, but dispenses with the naughty use of a module:
while(<DATA>){@x=split;for(@x){$o=/[.,]$/?2:1;$m=substr$_,0,1,''; $e=substr$_,-$o,$o,'';$m.=substr$_,rand(length),1,''while$_;$_="$m$e"} print"@x\n"}
__DATA__ Down that path lies madness. On the other hand, the road to hell is pa +ved with melting snowballs. Although the Perl Slogan is There's More Than One Way to Do It, I hesi +tate to make 10 ways to do something. And don't tell me there isn't one bit of difference between null and s +pace, because that's exactly how much difference there is. Randal said it would be tough to do in sed. He didn't say he didn't un +derstand sed. Randal understands sed quite well. Which is why he uses + Perl. As usual, I'm overstating the case to knock a few neurons loose, but t +he truth is usually somewhere in the muddle, uh, middle. Of course, I reserve the right to make wholly stupid changes to Perl i +f I think they improve the language.
Update: remove a few more chars, and some more (Thanks Bart), and some more (ditto)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fun with words (Golf?)
by Anonymous Monk on Nov 09, 2005 at 09:56 UTC |