Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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:??;

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
[Discipulus]: good morning nuns and monks!

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-06-20 06:43 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.