Since deobfuscating obfus helps me learn, an explanation follows:
Let's get it into proper format first:
$g ='* * * * * Just another Perl hacker. * * * * *'; $t=length $g; sub h{ select $9,$8,$7,pop } $|++; $r="\r".' 'x$t; print $g; h(1); { h(.15); print " $r\r@{[' 'x(($t-length $g)/2)]}$g"; do { die"$r\n" }unless $g=~s/(.)(.)/($1,$2)[rand(2)]/gex; redo }
Line by line:
$g ='* * * * * Just another Perl hacker. * * * * *'; ; $t=length $g;
Sets string $g to the specified value, and sets $t to 48, the length of $g. So far so good.
sub h{ select $9,$8,$7,pop }
4-arg select does some funky stuff with filehandles, but if the first 3 arguments are undef (which they are here), it simply sleeps for the time (in seconds) specified by the fourth argument, which, in this case, is the first argument for h. So h sleeps for any number of seconds that its argument specifies.
$|++;
Unbuffer the output, so characters show up on screen right as perl prints them.
$r="\r".' 'x$t; print $g;
Sets $r to a return character, followed by 48 spaces (the length of our JAPH string). Call this our clear string. A carriage return is NOT a newline. It brings the carriage to the beginning of a line but it does not advance the line. Thus, this string is effectively a "line clearer". Since the maximal string is only 48 characters, this string clears our line for all intents and purposes. Then, print the JAPH string.

h(1); { h(.15); print " $r\r@{[' 'x(($t-length $g)/2)]}$g";
Beginning the meat of the obfu here, we pause for one second, then begin a bare block which we will redo until certain conditions are met.

This bock begins by pausing for 1/6 of a second or so, and then prints our clear ($r) and returns to the beginning of the line. We have a blank line for printing. Now, it interpolates into the string a bunch of spaces, one for each two by which the current $g and its original length differ. Since we haven't changed $g yet, this is zero. Then we print the JAPH string.
do { die"$r\n" }unless $g=~s/(.)(.)/($1,$2)[rand(2)]/gex; redo
Let's examine the condition first: for every 2 characters in our japh string, we delete one. It now has a length of 48/2 = 24. If there are fewer than 2 characters left, then we die and print our clear string followed by a newline. Then, we go back to the blocks beginning to do it over. Let's look at the print statement for this next loop to get a feel for how it works:
print " $r\r@{[' 'x(($t-length $g)/2)]}$g";
Now, we print our control string and a return. Nothing new. But now, $t (the original length, 48) and length $g (the current length, 24), differ by 24, making it necessary to print 12 spaces at the beginning of the JAPH string. This has the effect of centering the string:
____________xxxxxxxxxxxxxxxxxxxxxxxx____________
Since the orignal string was 48 characters, printing 12 spaces at the beginning of the string keeps 24 characters centered in this 48 character "box". Rinse and repeat, halving the number of characters each time.

And that's it. The spaces keep it centered, and Kaiser JAPHy is never seen again.



Code is (almost) always untested.
http://www.justicepoetic.net/

In reply to SPOILERS Re: *Poof *, and it's gone. by jweed
in thread *Poof *, and it's gone. by davido

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.