Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

japhy's 2nd obfuscation review

by japhy (Canon)
on Aug 25, 2001 at 00:15 UTC ( #107688=obfuscated: print w/ replies, xml ) Need Help??

My current signature

Perhaps this looks familar to some of you. ;)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
Well, the first thing to notice is that we start with a substitution.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
We're using + as the delimiter. Clearing away the cruft, we have:
s//=END;/+y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
So this substitutes "=END;" for nothing, in $_. The next character is for addition; let's add some whitespace to help make this more visible.
s//=END;/ + y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
Next we have a translation via the y/// operator, which is just a sed-like synonym for tr///.
s//=END;/ + y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
The first set of characters has () as its delimiter, and the second set has }} as its. That's a sneaky little trick few Perl'ers know -- if you use a set of paired delimiters for the left-hand side of a s/// or a tr///, you can use ANY delimiter you want for the right-hand side; they don't have to use the same delimiter, or even be paired delimiters.

I'm also going to expand all the ranges in the classes, and structure it so you see exactly what gets changed to what. Notice how the interior of the right-hand side appears to contain two more y///'s -- one with y jjj and one that simply appears to be incomplete. Oh, and the ;-P is meant to be a smiley.

s//=END;/ + tr{;<=>?@ABCDEFGHIJKLMNOP}
              {y js++=;shajsj<++y(pq)}
If we remove all the unneeded junk, we see that we're merely replacing "=END;" with "japhy".
s//=END;/ + tr{;=DEN}
Next, we have a question mark -- at this point, it indicates the ternary operator, ?:. To its left, then, is the conditional. The conditional is the sum of our subtitution (1) and our translation (5), which is 6, a true value.
(s//=END;/ + tr/;=DEN/yjhap/) ? print : ??;
The expression executed for "true" is simply to print $_, which is what happens -- and "japhy" gets printed. The other expression is ??, which is an empty m?? regex. Although entirely unimportant and unrelated, the proximity of these ?'s to the other one is a "nice" thing.

Therefore, the code becomes:

(s//=END;/ + tr/;=DEN/yjhap/) ? print : ??;

# or

s//=END;/;        # $_ = "=END;"
tr/;=DEN/yjhap/;  # "=END;" => "japhy"
print;            # print $_

The True Nature of Perl

Here's a playful one that is meant to delight and amuse.
$^X and @ X=$^F**$^F;(
$^X )=(
$^X )=~m #perl#; die
$^X  =~m|[parley]{@X}|; $g or die(
$^X );chop(@  XX=q q3";q^(
$^X ));(
$^X )=~s|[parley]{@X}|@XX$/|cgi; $g or die(
$^X );
This was fun to write.

I'll get back to this one on Sunday. I'm leaving now for a weekend retreat with my fraternity.

Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Comment on japhy's 2nd obfuscation review
Replies are listed 'Best First'.
Re: japhy's 2nd obfuscation review
by tlhf (Scribe) on Aug 26, 2001 at 07:31 UTC
    I liked your 'delightful' one :) Took me a while to figure it out, but it's a bit sneaky in that's it almost all trickery magic. I got the obfuscated bit down too:
    ($^X ) = ($^X ) =~ m/^ |perl|;/g; @XX = '3"; ' ^ (per); ($^X ) =~ s/[perl]{4}/@XX/; print("$^X\n");
    The CGI bit comes from matching the '3"; ' ^ (per);. I especially liked the first $g or die, took me a while to realise the whole thing was a match starting with the $ on line 4.
Re: japhy's 2nd obfuscation review
by Sigmund (Pilgrim) on Aug 27, 2001 at 17:13 UTC
    Hey, buddy,
    this is great!!! i spent three hours trying to decipher your signature the morning before you posted explanations!!! I'm happy to see that i understood everything, but I said, it took me three hours!!!
    being honest, i hadn't understood the last two question marks...i didn't remrmber that the m in the m/// operator could be omitted!!!
    thanks for your lesson! it taught me many many things.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://107688]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2016-05-06 19:33 GMT
Find Nodes?
    Voting Booth?