Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

A Simple JAPH

by Athanasius (Chancellor)
on May 07, 2012 at 16:02 UTC ( #969289=obfuscated: print w/replies, xml ) Need Help??

My first effort:

$_='penflillggplmhlllpkolhmhgiokmpmhkegopckdlmlckemhge'; tr/g-p/0-9/;my@x=map{-84+hex$_}$_=~/[A-F0-9]{2}/gi;my@y= shift@x;push@y,$_+$y[-1]for@x;print join'',map{chr$_}@y;
“ ill-favoured thing, sir, but mine own.” —As You Like It (Act 5, Scene 4)


Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re: A Simple JAPH
by ambrus (Abbot) on May 07, 2012 at 21:09 UTC

    This obfu is nice because it's hard to see at first what it will print. Allow me a few minor comments though. (I'll use spoiler tags to not spoil anything for readers who hasn't decoded the obfu yet.)

    Firstly, it seems strange to me to see three apparently unnecessary mentions of $_ in a code like this: one after hex, one after chr, and you can remove the $_=~ part from the match too. Is there any reason you have these in the text?

    Secondly, is there a good reason to spell out the valid characters in the regex as /[A-F0-9]{2}/gi instead of just /../g or /\w\w/g? I could understand using a range like [A-F0-9] if you had extra invalid letters (from [s-z]) in the string that do nothing, but your string has no such letters. Writing [A-F0-9] gives an explicit clue to the reader that you are expecting hexadecimal digits. Is that what you want?

    Thirdly, the join'', part also seems unnecessary: print will concatenate the characters anyway.

    Lastly, I prefer if an obfu like this prints a newline after the message. This is not an absolute requirement, but if the obfu is easy to change to do this, then it's better that way. In this case, I think you'd just have to change the end of the long string from "mhge" to "mhgeji". If you think that would make the first line too long, just break the string to two lines. You can do this either by using two string literals like

    $_='first part'. 'second part'
    or by leaving whitespace in the string that your regex will skip, such as
    $_='first part second part'

    For example, after the changes I suggested above, plus some rearrangement to get the right edge of the text to line up again, I get this.

    $_='nflillggplmhlllpkolhmhgiokmpmhkegopckdlmlcke mhgejipe';tr/g-p/0-9/;my@x=map-84+hex,/\w./gi;my @y=pop@x;push@y,$_+$y[-1]for@x;print map{chr}@y;

    Let me list some specific good points of this obfu too.

      Wow! Thank-you ambrus for such detailed feedback.

      Taking (most of) your comments on board, the JAPH now looks like this:

      $_='penflillggplmhlllpkolhmhgiokmpmhkegopckdlmlck' .'emhgeji';y,g-p,0-9,;my@x=map{-84+hex}m;\w.;g;my@ y=shift@x;push@y,$_+$y[-1]for@x;print(map{chr}@y);

      I should have mentioned an additional requirement I imposed on myself: the code runs clean under use strict; and use warnings;

      This is fun!


      Athanasius <°(((><contra mundum

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://969289]
Approved by tobyink
[marto]: something isn't quite right, getting the "woah cowboy.." message when trying to say good morning, it wasn't the last thing I said in the CB :/
[Corion]: marto: Hmm - now you didn't get the "whoa cowboy" ;)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-02-28 09:32 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (399 votes). Check out past polls.