Hi Monks, Looking in my directories I found the code below, can anyone tell me what this code is trying to-do? Thanks a lot and here is the code.

#!/usr/bin/perl -nl BEGIN{($,,$0)=("\040",21);@F=(sub{tr[a-zA-Z][n-za-mN-ZA-M];print;}); $_="Gnxr 1-3 ng n gvzr, gur ynfg bar vf cbvfba.";&{$F[0]};sub t{*t=sub +{}; return if rand()<.5;$_="Vg'f abg lbhe ghea lrg, abj tb.";&{$F[0]};$_=0 +;} sub v{print map sprintf('%c', 2**7-2**2),(1 .. $0);}&v;}{$_++;$_--;$_| +|=4; if($_>>2||($_<<2>12)){$_="Vainyvq ragel";&{$F[0]};last;}&t;$0-=$_;$_=" +Lbh jva"; die(&{$F[0]}) if !($0-1);$0-=$0%2?$0>2?2:1:$0<=5?$0>2?3:1:rand>.5?1:3; $_="V jva";die(&{$F[0]}) if !($0-1>1);}&v

Replies are listed 'Best First'.
Re: Code Question
by davorg (Chancellor) on Dec 06, 2005 at 15:07 UTC
    can anyone tell me what this code is trying to-do

    It's trying to confuse you. Looks like it succeeded.

    Running it though B::Deparse gives the following, which might be a bit clearer.

    BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; { ++$_; --$_; $_ ||= 4; if ($_ >> 2 or $_ << 2 > 12) { $_ = 'Vainyvq ragel'; &{$F[0];}; last; } &t; $0 -= $_; $_ = 'Lbh jva'; die &{$F[0];} if not $0 - 1; $0 -= $0 % 2 ? ($0 > 2 ? 2 : 1) : ($0 <= 5 ? ($0 > 2 ? 3 : 1) +: (rand > 0.5 ? 1 : 3)); $_ = 'V jva'; die &{$F[0];} if not $0 - 1 > 1; } &v; }
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: Code Question
by gregor42 (Parson) on Dec 06, 2005 at 15:54 UTC

    This is a simple drinking game. The pipe characters "|" are supposed to be drinks lined up, wherein the last is poison. The object of the game is to choose how many drinks you want and to try to force 'your opponent' to have to drink the last glass.

    It is a very cute obfuscation. Pity there's no author attached to take proper credit.



    Wait! This isn't a Parachute, this is a Backpack!
Re: Code Question
by swampyankee (Parson) on Dec 06, 2005 at 15:44 UTC

    As a slightly higher level answer: Try running the strings through rot13; I think you'll decide it's a game

    emc

    Netlib
Re: Code Question
by blazar (Canon) on Dec 06, 2005 at 15:10 UTC
    Hi Monks, Looking in my directories I found the code below, can anyone tell me what this code is trying to-do?

    Winning an obfuscation competition...

    Try running it through perl -MO=Deparse.

Re: Code Question
by Perl Mouse (Chaplain) on Dec 06, 2005 at 16:47 UTC
    It either prints "Just another perl hacker,", or it contains a bug.
    Perl --((8:>*
      How did you run it?
        That's a joke.


        holli, /regexed monk/