Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Obfuscated Perl
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
apomb




PostPosted: Thu May 29, 2008 12:44 am   Post subject: Obfuscated Perl

Fascinates the pants off me.

I always wondered how anyone could be so proficient at Unix/Perl that they could write something like this:
Perl:
/;{}def/#{def}def/$_={/Times-Bold exch selectfont}#/_{rmoveto}#/"{dup}#/*/!/$
;/q{exch}#/x ; {/J q #}#/.{/T q #}#{stringwidth}#{}#{}# 14 string dup dup dup
260 40 moveto 90 rotate ; %/}};$0='"\e[7m \e[0m"';@ARGV=split//,reverse
q(ThePerl). q(Journal) x 220 ; q ; 0 T putinterval exch 7 J putinterval ;
 ; $_= q /m$ pop T($*!$"=!$ " )pop " * true% ? $ " $!" "  !!  !! % !" !"    !
! charpath {!"""}pop $ pop{""!}pop ! neg{!#}pop 220 ! neg _{!!}pop J false %T
charpath  clip "
pop 0 " moveto 6{!!}pop $_= 105{!!}pop {$ ! $ "#! ##}
pop{dup dup $ ! " pop pop q{"}pop 22{dup show}repeat {"}pop q 22 mul{$ "} pop
neg{!#! $ "}pop ! 8 .65 mul{$ # # $}pop ! neg{"}pop  _ pop{"}pop } repeat pop
" {  $ " ! ! ! $ " ! !" "#"  #"!"""""! #" " # "m/;@ARGV=(@ARGV[-14..-1])x50;q}
 0 "%};s/m[ou]|[-\dA-ln-z.\n_{}]|\$_=//gx;s/(.)(?{$*=''})/('$*.='.(++$#
%2?'':"
$0;").'pop;')x(ord($1)-31).'$*'/gee;s/((.(\e\[.m)*|.){77})/$1\n/g;print
; sub showpage {}
 


and the output be:
code:
ThePerlJournalThePerlJournalThePerlJournalThePerlJournalThePerlJournalThePerl
J     l hePerlJou     hePerlJourn  ThePe   ournalThePerlJournalThePerlJou  al
The erl ournalTheP rlJ urnalThePer Journa ThePerlJournalThePerlJournalTheP rl
Jou nal hePer  our alT e  rl o  na ThePer Jo   a  heP r J  rn l  ePe   our al
The erl   rn lT eP    o rn l  eP r Journa T ePe l our a  he e  Jo rnalT eP rl
Jou nal he e    ur alTh    l ourna Th Per J urn l heP r Journ lTh Pe    ur al
The erl ou n lTheP rlJo rnal hePer Jo rna T ePe l our a ThePe lJo rn lT eP rl
Jou nal he er   u   lThe   l ourn   he   lJo   alT   er Jour   T   e    u   l
ThePerlJournalThePerlJournalThePerlJournalThePerlJournalThePerlJournalThePerl


Protip: Highlight the code part and squint or, if you run any type of unix (mac included) just copy the code as obfuscated.pl and run it at your command line Wink
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: Thu May 29, 2008 1:33 am   Post subject: Re: Obfuscated Perl

I could write Hello World in Perl and it'd still look obfuscated Wink.

Seriously though, I really love the camel:
Perl:
#!/usr/bin/perl -w                                      # camel code
use strict;

                                           $_='ev
                                       al("seek\040D
           ATA,0,                  0;");foreach(1..3)
       {<DATA>;}my               @camel1hump;my$camel;
  my$Camel  ;while(             <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary           1=split(//);if(defined($
_=<DATA>)){@camel1hum        p=split(//);}while(@dromeda
 ry1){my$camel1hump=0      ;my$CAMEL=3;if(defined($_=shif
        t(@dromedary1    ))&&/\S/){$camel1hump+=1<<$CAMEL;}
       $CAMEL--;if(d   efined($_=shift(@dromedary1))&&/\S/){
      $camel1hump+=1  <<$CAMEL;}$CAMEL--;if(defined($_=shift(
     @camel1hump))&&/\S/){$camel1hump+=1<<$CAMEL;}$CAMEL--;if(
     defined($_=shift(@camel1hump))&&/\S/){$camel1hump+=1<<$CAME
     L;;}$camel.=(split(//,"\040..m`{/J\047\134}L^7FX"))[$camel1h
      ump];}$camel.="\n";}@camel1hump=split(/\n/,$camel);foreach(@
      camel1hump){chomp;$Camel=$_;y/LJF7\173\175`\047/\061\062\063\
      064\065\066\067\070/;y/12345678/JL7F\175\173\047`/;$_=reverse;
       print"$_\040$Camel\n";}foreach(@camel1hump){chomp;$Camel=$_;y
        /LJF7\173\175`\047/12345678/;y/12345678/JL7F\175\173\0 47`/;
         $_=reverse;print"\040$_$Camel\n";}'
;;s/\s*//g;;eval;   eval
           ("seek\040DATA,0,0;");undef$/;$_=<DATA>;s/\s*//g;(   );;s
             ;^.*_;;;map{eval"print\"$_\"";}/.{4}/g; __DATA__   \124
               \1   50\145\040\165\163\145\040\157\1 46\040\1  41\0
                    40\143\141  \155\145\1 54\040\1   51\155141
                    \147\145\0  40\151\156 \040\141    \163\16 3\
                     157\143\   151\141\16  4\151\1     57\156
                     \040\167  \151\164\1   50\040\      120\1
                     45\162\   154\040\15    1\163\      040\14
                     1\040\1   64\162\1      41\144       \145\
                     155\14    1\162\       153\04        0\157
                      \146\     040\11     7\047\         122\1
                      45\15      1\154\1  54\171          \040
                      \046\         012\101\16            3\16
                      3\15           7\143\15             1\14
                      1\16            4\145\163           \054
                     \040            \111\156\14         3\056
                    \040\         125\163\145\14         4\040\
                    167\1        51\164\1  50\0         40\160\
                  145\162                              \155\151
                \163\163                                \151\1
              57\156\056

It's so obfuscated it appears to break the syntax highlighting.

Edit: It outputs this over and over again:

code:
                    .mJXXLm                  mJXXLm.                   
    .mJXXL       .JXXXXXXXXL                JXXXXXXXXL.       JXXLm.   
 mXXXXmXXXL     .XXXXXXXXXXX}              {XXXXXXXXXXX.     JXXXmXXXXm
 7XXXXXXXXX}  .JXXXXXXXXXXXXX.            .XXXXXXXXXXXXXL.  {XXXXXXXXXF
    .XXXXXX'.JXXXXXXXXXXXXXXXXL          JXXXXXXXXXXXXXXXXL.`XXXXXX.   
   .XXXXXXXmXXXXXXXXXXXXXXXXXXXL        JXXXXXXXXXXXXXXXXXXXmXXXXXXX. 
   {XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.    .XXXXXXXXXXXXXXXXXXXXXXXXXXXXX} 
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.  .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   
    7XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXF   
     7XXXXXXXXXXXXXXXXXXXXXXXXXF`XX  XX'7XXXXXXXXXXXXXXXXXXXXXXXXXF   
      `7XXXXXXXXXXXXXXXXXXX7XXX} XX  XX {XXXFXXXXXXXXXXXXXXXXXXXF'     
        `' XXXXX^XXXXX7XXXF`XXX}{X'  `X}{XXX'7XXXFXXXXX^XXXXX `'       
           7XXXF XXXXX`XXX} `XXX`'    `'XXX' {XXX'XXXXX 7XXXF         
           {XXX'{XXXX} 7XX}  {XX.      .XX}  {XXF {XXXX}`XXX}         
           {XXF {XXF'  JXX'   XX}      {XX   `XXL  `7XX} 7XX}         
            XX}  7XXm JXX'    XX'      `XX    `XXL mXXF  {XX           
            XX'    7XXXF      XX        XX      7XXXF    `XX           
           .XF     .XXXXL    .XX        XX.    JXXXX.     7X.         
           XX}   .XXXF7XF    JXX}      {XXL    7XF7XXX.   {XX         
         mXXX'              `XXX'      `XXX'              `XXXm       
        ^^^^^                                              ^^^^^ 
rizzix




PostPosted: Thu May 29, 2008 9:05 am   Post subject: RE:Obfuscated Perl

It's very easy to obfuscate code. It's much harder to decrypt obfuscated code.
Prabhakar Ragde




PostPosted: Sat May 31, 2008 6:36 am   Post subject: RE:Obfuscated Perl

It's very easy to write obfuscated Perl. It's much harder to write clear Perl. --PR
wtd




PostPosted: Sat May 31, 2008 11:41 am   Post subject: RE:Obfuscated Perl

I find it rather easy to write clear Perl, actually. It's just a matter of actually knowing the language and understanding its idioms.
michaelp




PostPosted: Sat May 31, 2008 6:05 pm   Post subject: RE:Obfuscated Perl

I'm wondering how that can even be code. Razz
I was thinking about using Perl as a new language to learn, but then I decided to learn Python instead. Very Happy
apomb




PostPosted: Mon Jun 02, 2008 12:35 pm   Post subject: RE:Obfuscated Perl

I, too am enjoying writing clear perl programs, this diversion into obfuscation is just entertainment.

I'm finally seeing the power of simplicity.
wtd




PostPosted: Mon Jun 02, 2008 12:46 pm   Post subject: RE:Obfuscated Perl

The biggest "wow!" when I first learned Perl all those years ago was probably having powerful data structures (arrays, hashes) at my disposal, and having them very easily accessible.

Not to say this is exclusively a Perl advantage, but it still gets it more right than a lot of other, more popular languages.

Oh, and once you "get" how the Perl type system works, it's a lot easier to understand the whole thing.
Sponsor
Sponsor
Sponsor
sponsor
apomb




PostPosted: Wed Jun 11, 2008 1:33 pm   Post subject: RE:Obfuscated Perl

I find Ruby and perl similar in that regard, wtd, since ive gotten equally into both languages.
wtd




PostPosted: Wed Jun 11, 2008 2:44 pm   Post subject: RE:Obfuscated Perl

I thought you would. It really is one of their great strengths, especially as it helps with keeping the library simple.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: