Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Output of mindfcuk

by dewey (Pilgrim)
on Jun 09, 2007 at 17:59 UTC ( [id://620208]=note: print w/replies, xml ) Need Help??


in reply to Output of mindfcuk

What exactly do you need help understanding? If you know what each line does, you just need to sit down with a piece of paper and start keeping track of what everything is (basically run the program yourself). If you don't know what a line does, there are some good resources online for learning perl, or you can look it up in perldoc. Does that help you get started?

~dewey

Replies are listed 'Best First'.
Re^2: Output of mindfcuk
by Anonymous Monk on Jun 10, 2007 at 01:05 UTC

    Yes, I did that. I had worked on it before posting.

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

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

        Thank you, blazar.

        The sad thing (for me) is I went through almost every part of the code and I understand about 90% of what's going on at every interval point (set by me). Yet, I can't seem to have an idea of what username is required by the program. Here's a snippet of my debugging attempt:
        print "\nm1: $m[$p]\n"; $m[$p]+=3; print "p1: $p\n"; print "\nm2: $m[$p]\n"; print "\nAt the beginning2\n"; for $i (0..@m) { print "m${i}: $m[$i]\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://620208]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found