in reply to A first attempt

Its a good start. I give it a ++.

Some ideas: You don't need to my the $a ($a is a magic variable used by sort.) I might try the same approach like this:

$_=q; uJts natoehr ePlr ahkcre.;; $a=q#s<([a-z])([a-z])>@$2$1@ig;; #;eval($a)=>$b.=qq=$_ =for split;print $b,$/

Replies are listed 'Best First'.
RE: A first attempt
by tedv (Pilgrim) on Oct 28, 2000 at 04:26 UTC
    It's also a good idea to use \w instead of [a-z], even if that also catches upper case and underscores. Random escaped regexp characters are much harder to sync up in your mind than character ranges. So your regexp looks like this:
    s<(\w)(\w)>#$2$1#g

    Notice how you don't need the /i tag anymore either. Of course, you might as well use /ge if you're using a substitution. Maybe try this:
    s<(\w\w)>@reverse split m{},$1@ge


    -Ted
      You are, of course, correct! I don't know why I didn't notice that. How about:
      @_=qw=PerlMonksRock!=;$_=q; uJts natoehr ePlr ahkcre.;; $a=q#s<(\D)(\w)>@$+$1@g;;1; #;;eval($a)=>$b.=qq=$_ =for split;;print $b,$/,#@PM.ORG
      By the way, obfuscation is fun because it forces you to learn the more 'obscure' parts of Perl. Half the fun is trying to figure out how it works, and then diving into the library to fill in the gaps. You can find out about all the predefined variables this way too.