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... |