Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Obfuscated code

( #1597=superdoc: print w/replies, xml ) Need Help??

Got some code which would take a Perl grand master to understand without running it? Post it in this section so we can stare at it in awe.

Word of warning, though: Don't be too cocky with your post — almost inevitably someone will post a reply that does the exact same thing in even fewer characters!

New Less than Readable Code
Larry Wall
2 direct replies — Read more / Contribute
by usemodperl
on Jun 17, 2018 at 22:19
    perl -e '$_=`perl -v`;while(/\d\,(\s\x4c[^\n]+)/){print$1}'

    Edit: It prints a lot! If that annoys you try the static version:

    perl -le '$_=`perl -v`;if(/\d\,\s(\x4c[^\n]+)/){print$1}'
A quick one-liner
No replies — Read more | Post response
by liverpole
on Jun 11, 2018 at 20:19
    Should work on most *nix systems:
    perl -E'say`$^Xdoc -qj`=~m`"(.*)"`'

Happy birthday, happy birthday... happy birthday to Perl!
1 direct reply — Read more / Contribute
by Discipulus
on Dec 18, 2017 at 02:49
    # ### ##0## ### # ;while( #=30==# <DATA>) {chomp; s{#}{}g #==30=# ;3;s{0} {\n}g;; #=30==# ;s{\d}{ " "x $& }xge;print}BEGIN{print$/,(" "x14),(join" - ",( map{join" ",(split/\s/,scalar gmtime$_)[1,2,4] }566784000,1513555200)),$/};END{seek DATA,0,0; print" "x 4,$_ while<DATA>}30;30;__DATA__###30 9_2_2_7_2_7_2_2_2_108|_||_1|_|1|4_||1|2\1/|_1| #_||_||_108|2|_1|1\1|_3_||_|3/1|_1|1||1\1_|10#


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Langton's Obfuscation
No replies — Read more | Post response
by golux
on Oct 29, 2017 at 01:22
    After watching this very interesting video, I decided it just had to be made into an obfuscation. After completion I realized it had been more than a year since I had composed one -- time flies. As usual, more information can be found at Wikipedia.

    You'll need to have perl/Tk installed to run it. Invoke it with perl <program> (or in Windows give it a .pl extension). I won't give away too much, except to say that the shape of the code hints at the ultimate outcome.

    When first run, type the <space> key to start progress. You can then type <space> again to pause or restart. The number of "cycles" (or "generations") displays in the invoking window after each subsequent pause.

    Two parameters may be given; both are optional.

    The first is an integer that says how many "cycles" to run before changing colors. It defaults to a value which is more obvious when you run the code. Try for example a value of '350'.

    The second is the delay in milliseconds between successive "cycles"; use a larger value to slow down execution. The default is '1' (fastest possible).

    s""v tf!Ul <)%c- %e-%y -%z- %l-% d*>) 1-3-4 1-34- 1-(g1 1(*<% p>tij gu}}2 1111 <%E>t ijgu }}2< %N>Nb joXjo epx.? ofx)* <%N.? ujumf )rr| #Mbo hupo (t!B ou#~* <%w>% N.?Db owbt) .xj>? 911-. if>? 623* .?qb dl<n bq|% w.?d sfbuf Mjof) 9+%`- 1-9+% `-623 *<%w. ?dsfb ufMjo f)1-9 +%`-9 11-9+ %`*~) 2//: :*<' `''% N.?c joe) #=tq bdf? #>?t vc|,, %c&3} }qsjo u#Dpv ou;%l ]o#~* <tvc! s|sbo e)27* ~tvc! `|%w. ?efmf uf)% t*<% t>%w .?ds fbuf Sfdu bohm f)d) (111( **~tv c!d|) 9+%y. 5-9+) 75.%z *.5-9 +%y,5 -9+)7 5.%z* ,5-.g j>?di s)46 */%` [1^* ~%N. ?sfq fbu) %E>? tvc|j g)%c& 3''%l ,,=23 81:*| %j>21 1+%z, %y<%g >%g[% j^<% f>%g @.2; 2<%w .?ef mfuf )%g*< %g[%j ^>%g@ (1(;% w.?ds fbuf Pwbm) d)%d* *<%e& 3boe %z,> %e=3 @.%f ;%f< %e&3 ps%y, >%e@. %f;%f <%e>) %e,%f *&5<' `<%l& %p!ps %d>tq sjou g(&y &y&y (-'s -'s-' s~~*< %N.?N bjoMp pq";s,\s,,g;s;([^[]);chr(ord($1)-1);ge,eval
    say  substr+lc crypt(qw $i3 SI$),4,5
Predecrement a constant?
1 direct reply — Read more / Contribute
by monsoon
on Feb 28, 2017 at 02:14

    Not much obfuscation really. The idea was to try and see if it was possible with some unusual code to predecrement a constant or at least to pretend to do so.

    *0=sub: lvalue {my$l}, print --0 ->(!0)
Dungeons and Dragons die roller (Golf)
4 direct replies — Read more / Contribute
by zsl
on Sep 30, 2016 at 16:18

    60 byte solution, not counting hashbang, to take strings that look like '2d4' or '2d4+10' and give you the result:

    -n ($d,$s,$=)=split/d|\+/;$=+=1+rand $s for 1..$d;print$=,$/

    Anyone wants to try and beat my record?

Another japh
No replies — Read more | Post response
by Mandrake
on Aug 03, 2016 at 21:43
    Had a bit of spare time today !
    {sub OrO{OrOOr (eval(chr(@_[0])))}}push @Or,++$_ for(0..(++$_*++$_)*++$_);{sub OrOOr{print@_[0]}} OrO(Or(Or0()+1+Or0(),Or0()+1))&&OrO(Or(Or0()+Or0(), Or0()+Or0()/(Or0()-2)))&&OrO(Or(0,(Or0()*(Or0()-1) -1)))&&OrO(Or(Or0()*2+1,(Or0()*2+1)/(Or0()-1)));sub Or{$Or[@_[0]].$Or[@_[1]]}sub Or0{$_= "\[\[\[\[";$_=((split//));}
Self-constructing Japh
1 direct reply — Read more / Contribute
by golux
on Jul 30, 2016 at 17:37
    It's been a while. Here's an obfuscated script written over 4 years ago that finally got finished up. Though it technically works in Windows with "perl -MWin32::Console::ANSI <script>", it looks much better in Linux or MacOS (or probably Cygwin), for which it was designed, as it uses ansi escape sequences.

    Note: to change the speed give an optional delay argument in fractions of a second. The default is 0.1 (ie. 0.5 would be slower, 0.05 faster).

    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"
    say  substr+lc crypt(qw $i3 SI$),4,5
Having fun with ambiguity
No replies — Read more | Post response
by trizen
on May 23, 2016 at 14:30
    print $$ /0; # a legit division by zero ^....some.....^ ^^ ^....magic....^ |(?{m}(?{"\[\[\) \.\\\|\`\]\[\[\{ \[\.\@\/\(\^\.\[ \{\;\\\,\[\@\:\? \+\^\)\("=~s\}[\ \s]\}\}rg^"\+\)\ \@\@\(\^\*\(\(\/ \[\:\@\/\[\@\;\\ \{\+\^\.\@\{\(\[ \\\@\;\[\"\""=~s \}\s\}\}gr\})},s \/\/$^R\/esex})| ^....hugs....^ ^.....&......^ ^...kisses...^ // //xo//xo//xo//xo//xo//xo//xo// //
Test Post to check new edit feature
1 direct reply — Read more / Contribute
by LanX
on Mar 10, 2016 at 17:14
    If you are a cabal and want to test jdporter's new edit/update button reply in this thread. We can delete later again.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Set the new obfuscation standard
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (8)
    As of 2018-06-20 13:34 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.