Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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
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 ^....super....^ ^^ ^....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!

Using the olde times internet
3 direct replies — Read more / Contribute
by lemonCurd
on Feb 14, 2016 at 09:45

    I'm contemplating about this very little piece of Perl code. I'm already more than a little bit proud of it, but I wondered if the venerated Monks had suggestions to make it even shorter:

    print"@ARGV"=~s|.|$_=2+index'temaniowkugrdsXjyqxvpcfzlbh',lc$&;$Q= 1.45*log;$_-=1<<$Q;for($O='';--$Q>0;$_/=2){$O.=chr$_%2+45}"$O "|ger

    Try it with some text as command line arguments.

    Especially I'm curious about:

    • Is there any way to avoid initializing $O?
    • I use $Q=1.45*log to approximate the number of bits in $_. Any shorter way?
    Every comment is very much appreciated!

    2/15/2016: Corrected two typos!

Not a golf but a wish..
1 direct reply — Read more / Contribute
by Discipulus
on Dec 23, 2015 at 04:50
    i've been inspired by this code by LanX and mtve (read: i've stolen their golfs as the base..)
    to produce something for you all, which intent is clear from BEGIN where the root of every (binary?) tree sleeps...
    not a golf but a wish!
    # ## ##!/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'MSWin32'?'cls':'clear';$^W=0}
    Justin Case there is gift under the tree..

    update: changed the BEGIN block to be more inclusive..

    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.
/dev/rand quoting practice
No replies — Read more | Post response
by ohcamacj
on Oct 13, 2015 at 10:05

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 the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (3)
    As of 2018-12-11 18:41 GMT
    Find Nodes?
      Voting Booth?
      How many stories does it take before you've heard them all?

      Results (56 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!