I'm still not able to figure what is happening in the middle part, with so many "while" loops.

You see, the Perl code is simple in that it uses a very limited subset of the language. And it is complex in that it uses lots of construct from that subset to do thing that in "proper" Perl would take a single statement. Thus you may look at it as an obfu demunging exercise, the point being here, that single steps are easily understandable. To grasp the overall picture is purely a matter of having the time and the will to follow them all. (Perhaps running in the debugger could help.) As an example consider the following excerpt, chosen randomly:

while($m[$p]){ $p-=1; $m[$p]+=10; $p+=1; $m[$p]-=1; } $p-=1; $m[$p]+=3; $p+=1; $m[$p]=ord getc; print chr$m[$p];

The first loop repeatedly modifies $p by respectively adding and subtracting one to it, so that in fact it just bounces between two values which are respectively its initial one, say $p, and $p-1. It repeatedly subtracts one to the former until it become zero and adds ten to the latter. Without using a loop that amounts to

$m[$p-1] += 10 * $m[$p]; $m[$p] = 0;

The second assignment is redundant though, because the value is not used later before it gets assigned something completely different. Then ord and chr are inverse functions, so except for the side effect of assigning to $m[$p], the last two statements just amount to

print getc;

And so on...


In reply to Re^3: Output of mindfcuk by blazar
in thread Output of mindfcuk by Anonymous Monk

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.