Here's a breakdown of the code:
#!/usr/bin/perl -w use strict;
No explanation needed
$_="Perl in a box"; for(/\S/g){ @_=(@_=>lc) }
Put all of the characters from $_ into @_ in order after they've been lower cased, but no spaces.
my($i,$k)=(0,'');
Variable decalaration
for(@_){ $_{$_}=$i++ }
Sets up the magic decoder ring for the first level encoding. For each character in @_, set a value in %_ for the key corresponding to the character to the offset in @_. i.e. $_{p} = 0, $_{e} = 1, etc.
undef $/; $_=<DATA>;
Unset the input record separator and slurp in the encoded info in from DATA.
s;\s;;g; for(/../g){
After blowing away all whitespace in the encoded data, loop over the data 2 characters at a time.
my@k=/./g;
Split the characters into @k.
@k=(pop@k,@k)if($k[1]ne lc$k[1]);
Reverse the characters in the array if the second one is not lower case.
for my $k (@k){ $k=$_{lc$k}; }
Decode the letters in @k with the magic decoder ring to get 2 numbers.
$k.=chr(30+pop(@k)+10*pop(@k));
Multiply the first number in @k by 10, add 30 and the first number in @k, turn it into a character and add it onto the string $k, which is different than the $k we used in the for loop above.
}
End the for(/../g) loop
$_=$k; s|(.{20})|$1\n|g;
Assign $k to $_ so the substitution looks better and do the substitution to turn $_ into 20 character long lines.
eval
Eval the second obfuscated code. Wheew. Are we done yet? Nope. Here's what the second level decoder looks like:
$_=q[s;.*;94eae6e840 c2dcdee8d0cae440a0ca e4 d8 40 d0 c2 c6 d6 ca e4 14 ;s ;@ _= /. ./ g; fo r( @_ ){ $_ =c hr (( he x) >>1)}$_=join'',@_;pr int];s; |\n;;g;eval;
In a slightly more readable form:
$_=q[ s;.*;94eae6e840c2dcdee8d0cae440a0cae4d840d0c2c6d6cae414;s; @_=/../g; for(@_){ $_=chr((hex)>>1); } $_=join'',@_; print ]; s; |\n;;g; eval;
This code simply sets up more code that loops through the encoded string (The 94eae6.... string that is put into $_ inside the quoted code to be evaled) 2 characters at a time, turns those characters into a real hex value, which in turn is shifted right 1 bit and turned into a character. After all of the characters have been decoded, they are crammed together and printed. A nice head-scratcher.

In reply to Re: Perl in a box by bschmer
in thread Perl in a box by CheeseLord

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.