LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2017, 06:30 PM   #16
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Original Poster
Rep: Reputation: 143Reputation: 143

[QUOTE=sundialsvcs;5702450]Likewise, Perl shows an unmistakable influence of awk, which it was (in one sense) "built to replace."/QUOTE]

More like sed and awk. Those two are always paired together. The O'Reilly books even just have one book to cover both of them.
 
Old 05-03-2017, 06:36 PM   #17
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Original Poster
Rep: Reputation: 143Reputation: 143
Quote:
Originally Posted by camp0 View Post
The main reason is that I find hard to read the code. I remember that we got a script of 300.000 lines of perl and was a pain and nobody wanted to touch it. Another reason to not use perl is that if you want to mix with other libs I found more useful libs under python and if you need to mix with c or c++ is easy than in perl.
That's probably because the programmer was being too clever by half. It's actually quite easy to write easily readable Perl code (except regular expressions, but that's true for all languages that have them). There's even a contest, or at least was, as to come up with the most obfuscated hard-to-read Perl you possibly could make.



OMG, I just found a VERY COOL ONE, you all have to run it. Just type perl, paste it in, then press return and then Control-D.

Code:
 die+eval(q{$|=pr      int"\e[        2J\n";$k='       |';s       ,,2
220;3500731;352273  5071;16007150   74;1622713,x;y;   0-4;8|    _/%;;s
;5;\e[103m;g;s,6, \e[102m,g;s;7;\e  [m;g;$/=$_;$_=q|  hb2Gbb    5hhDei
      4dh0Bh      lFbi20    1hoC4d  o0CdsB    bp201h  vDev5d    v0ChzG
      |;s;[1      -9];>$&;g;s;[A-I  ];^$&;g;y|A-I|1-  9|;{s;^(\w)(\w);
      ;x?($y      =-97+ord$1,$x=-9  7+ord$2):s,^0,,   ?$k='/':s,^([>^]
      )(\d),      ,?map{$c=$1,$X=1  +3*$x,$Y=$y*      2,$Z=4;$"=$/=~s;
      %;$k;r      ;map{p    rint"\  e[${\$Y           ++};${    X}H$_"
  ;$X--if++$      Z<7}sp    lit';'  ,$";$k=           '|';se    lect$J
 ,$a,$p,$ARG      V[0]||    .1;'^'  eq$c?$y           --:$x+    +}1..$
2:last;redo       }}=~y     %8 \n   % %dr),           "\e[".   "22H\n"
This is cool too:

Code:
print $$ /0;        # a legit division by zero

 ^....some.....^
^....black....^
^....magic....^

|(?{m}(?{"\[\[\)
\.\\\|\`\]\[\[\{
\[\.\@\/\(\^\.\[
\{\;\\\,\[\@\:\?
\+\^\)\("=~s\}[\
\s]\}\}rg^"\+\)\
\@\@\(\^\*\(\(\/
\[\:\@\/\[\@\;\\
\{\+\^\.\@\{\(\[
\\\@\;\[\"\""=~s
\}\s\}\}gr\})},s
\/\/$^R\/esex})|

^....hugs....^
^.....&......^
^...kisses...^

 //
//xo//xo//xo//xo//xo//xo//xo//
                           //
Cool, if a bit outdated -- let it run it takes a few minutes...
Code:
                        #
                      ## ##!/env/perl
                       # #
                        $}
                       ;$|
                       ++;
                      $p;$x;
                      #\*/#
                     foreach
                    $b( split
                   '\+','+0+77+
                  -8+13+0+7+-57
                  //\\//\\//\\/
                 +35+5+10+-9+10+1
                +-7+-12+18+-51+ 33
               //\\//\\//\\//\\//\\
              +13+-10+-36+40+-7+15+0+
             9+-57+46+-9+18+-55+57+-20
           //\\//\\//\\//\\//\\//\\//\\
         +-4+17+-50+18+-2+1+5+-44+22+0+0+
        52+-5+-47+57+-10+6+-53+33+11+0+-44
       //\\//\\//\\//\\//\\//\\//\\//\\//\\
      +48+-11+13+-6+1+2+-1+-3+8+-51+38+12+-3+
     -2+-45+36+5+10+-16+6+7+5+-9+9+-2+-51+0+10
    //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
   +-32+0'){system$};eval 'printf qq(%22s%s\n), $_
 %=21,$_=4**$_,y/0/^/c,s/0/$b<0?o:O/eeee for 1..23';
print $y.= chr($x += $p);$p = $b; sleep 1 } print chr(
                        $x
                        +=
                        $p
                        ) ;
      # BEGIN{$}=$^O eq'Linux'?'clear':'cls';$^W=0}
      BEGIN{$}=$^O   eq'Win32'?'cls':'clear';$^W=0}
Code:
s/l*(6'6keN4-\$D)?/Vi32kUZ0>dcWe{}E\\T7\@",}u's<6(\@&-f)H=_O={8KL='\\=#n\/#w\$zfr}vf\$3M:g:AV"!/;
#Y\off/G_gq!"q& ])c_k&xrU's\?s9W=e26^+OMBs`,>]=g70Qinx=+/2D8N{],GzO}}0w"Fe`o!h%uoCB#z6ywUA!!*/H
$k=unpack("B*", ")AM:7!]]>'I+\%Q=W!!42,30Q16!220\\9!QM=54,E5\x20U+!\&A)-SU2#\%D\\+4059!U,\x20"
."\x20]0\&\%T6\x20QP)\&\x20-30\&-5\%5T=.\x20\x20(");$k=~s/.(.).(.{5})/$1$2/gx;$_^=pack("B*",
$k);eval;qq<r^47cGA\&fK(U"'55aK?|(N^1nl]+q.)^CA[d#-VN6_|-z\$[\\nJJQKO8;uFa;\&5;!"" ^2)uV'.TF
s^W:5)_\@!`87)8\<7Vd!Z9J^kT\$?]2\@Q*Zq?I#hb\>`jX"o2yL`sd(Z9/se/6=K\>Y[S-wa?-s.A8":Kv2 ,14
\&~{NU-/\@_]Mj_|\@5;2\&m\<GVb'h5\&?x\>Qo4Hm[)B3)\@pvoz(}]\$0sRb{^5v7B c.13;U"J0vek'-'B>

Last edited by Laserbeak; 05-03-2017 at 07:16 PM. Reason: add more obfuscated perl
 
Old 05-03-2017, 07:13 PM   #18
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
While I can appreciate obfuscated perlisms at times, I would not want to see LQ programming forum become an archive of "paste this and see what cool stuff it does!" code snippets!

Even when we know the source, we must remind random visitors to always use due caution when engaged in potentially risky activities!

One typo or changed character encoding might be the difference between an amused giggle, and a compromised or borked system!
 
Old 05-03-2017, 07:48 PM   #19
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Meh ... Guess we're all too busy doing our jobs!

Quote:
"Okay, okay, okay ... this script ... what language was it originally written in?" Okay, so I gotta hurry-up and put on that language-hat."

(Now, please remind me, "which language-hat was it ...?")
- - -

Hmmm.... if we allow "future programmers" to actually see what 'the job' is sometimes actually 'like,' they might all decide to become "<<>>'s," instead!

Last edited by sundialsvcs; 05-03-2017 at 07:55 PM.
 
Old 05-03-2017, 08:05 PM   #20
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,264
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Not a complaint, just a reminder to be safe, especially important when having... fun!

Last edited by astrogeek; 05-03-2017 at 08:10 PM.
 
Old 05-03-2017, 09:14 PM   #21
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Original Poster
Rep: Reputation: 143Reputation: 143
Quote:
Originally Posted by camp0 View Post
if you need to mix with c or c++ is easy than in perl.
This is palpably untrue.

You can actually compile a Perl engine into your C/C++ program then Perl runs in the same process (no fork()s), it basically becomes an extension of the C language.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python vs perl doughyi8u Programming 14 03-03-2016 11:03 AM
Python related: How to access a Perl script behind a firewall from Python? vxc69 Programming 8 12-14-2010 07:32 AM
Perl Vs python knockout_artist Linux - Newbie 6 10-15-2008 11:06 AM
My needs: Perl vs. Python dave201 Programming 25 08-11-2007 11:13 PM
Perl or Python ! linuxlover1 Programming 13 04-19-2004 07:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration