Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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
Felling a tree JAPH
2 direct replies — Read more / Contribute
by MidLifeXis
on Aug 30, 2013 at 10:28

    Still not a great JAPH, and it exceeds 4x79, but it is more obfuscated than yesterday's.

    # Cutting down a tree $t=t->p;$t->g;$t->f;sub t::p{@n=map{x($_)}'Just another Perl hacker,'= +~m/(.)/g; bless{n=>\@n},$_[0]}sub t::g{$_[0]->{t}=$_[0]->f(0,$#{$_[0]->{n}});$_[ +0]->{n}=1 ;$_[0]}sub t::f{($a,$b,$e)=@_;$m=int(($b+$e)/2);$f=$_[0]->{n}[$m];$l=$ +_[0]->f( $b,$m-1)if$b<$m;$r=$_[0]->f($m+1,$e)if$m<$e;bless [$l,$f,$r],'f'}sub t +::f{$_[0] ->{t}=1}sub x{bless \$_[0],"x"}sub x::DESTROY{print${$_[0]}}sub f::DES +TROY{$_[0 ]->[$_]=1 for(0..2)}

    --MidLifeXis

Destructive JAPH
1 direct reply — Read more / Contribute
by MidLifeXis
on Aug 29, 2013 at 10:48

    Starting my foray into JAPH to explore various aspects and corners of the language. Not necessarily obfuscated, but more using different aspects of Perl to accomplish the goals of a JAPH. 4x79 code max, Just another Perl hacker, output to stdout. I am hoping to explore a different technique each day, but it will probably devolve to one a week.

    This implementation is pretty obvious how it works, but it uses the DESTROY method of object destruction to output the characters of the output.

    @x = map{ x($_) } split('','Just another Perl hacker,'); shift(@x) while @x; sub x{ bless \$_[0],"x"} sub x::DESTROY{print ${$_[0]}}

    --MidLifeXis

Undefined JAPH
5 direct replies — Read more / Contribute
by ateague
on Aug 28, 2013 at 19:08

    It is simply amazing what Perl's undef can do if you just ask it nicely. I got mine to print JAPH.

    UPDATE! Spoiler available!

    #!/usr/bin/perl {{{{THE:{{{{END:{{{{IS:{{{{THE:{{{BEGINNING:{{{{IS:{{{{THE:{{{{END{{{{ no strict; no warnings;# Where we're going, we won't need eyes to see. undef->('J')->('u') ->('s')->('t') ->(' ')->('a') ->('n')->('o') ->('t')->('h') ->('e')->('r') ->(' ')->('P') ->('e')->('r') ->('l')->(' ') ->('h')->('a') ->('c')->('k') ->('e')->('r') ->((qq(\n)));# ALONE CANNOT YOU IT RESIST ;};};};};};};};};};};};};};};};};};};};};};};};};};};};};};};};};};};} use strict;use warnings FATAL=>'all';use utf8;use 5.014;# It begins... eval((eval(join'',join'',map{unpack'C/(C.*/X/xa@)'}split/\n/,<<'MAGIC' "BC8D%5/.31420-A69=(#:*$+<@;?)&',>7""$''((*,,;<=>AADTaaabchijkmnopsu{" ">DC95'A<?36;(%B&-#4*.=@8)$2+/0,17:$$''((())),,,1?_aacccdehknoppruuv{" "?'=@:(#8)721*3%&CA><;B./-$9506+,D4$$''(()))),//046:;[]^__diloprrst}}" MAGIC ))->(# LASCIATE OGNI SPERANZA VOI CH'ENTRATE. LIBERATE TUTAME EX JAPH! <<'MORE MAGIC' $_='open(necromicon)and(seek(undef,undef)) ((4SO)EPL(M)(6)(yv5((76aW((65(s&gxVH7Z(2f) (2)ud)b))J06)r7m(6i)oO)L)(MF)T6(yv(E(6a((( sgVxHZE(f)(!61P)u20d)b))J6)$76rm9(i7)So66( 52O07))L9)6(FS75M)2(07((y5)7V0)v2((UCa(((W sg0TAxH4Z(fE)udW)65b))J!P76)rm65(i)oO)7L)( M)(22V)(yv0R67((a(6(F6(sEgxY6HZ(Ef)6(1)ud2 )Tb06))JC)rm(i )o6O)L)5%(VTW7 U4VM2)(y0v((a( (sgxH7Z(f)(R)9 6WFud)%bV)J)rm (i7Q)o5VO2)06L )#4(6FV7M)76E( y0vA((a((S(Wsg !4Ex6HZ5(Sf7)u d)b6))6J)r!m(i )S57oSO)L)(M2U )2067(6yFv((6E 6aE6(VW((sgxH1 Z(f)ud2)b0)R7U 2)J7)56rm(E2iU )o0TO)LQ)6(M)( y1v((a(7T(2(6s F7gxHZ(fT)u5Td )b))&J6)rm(Ei) o64O)L)(M)20(6 T1)6(y%v(E6(Ta ((#(T((oh.god.how.did.this.get.here.i.am.not.good.with.computer)4g2)(Y xUH)Z(0f6)ud4)b)6)5J)rm7(i)oO)XL)3(M)(yR#Uv((6a((s57(gU27(x4HWZ))(2f0% )(79)udVb6)F7T)50VJ)AUV4rE65m7(i)oO)L)V(MV6)#6(yv(572(a(2((sgxH0Z(f676 )(F6uEd6R))b)E)J)PrS6mY(i)oO)L)(M)(12yv((a((0(sgxHZ6RD"(f61)6(B6S)ud)b 52))J)rm(i)oOP)L0)(7M96)(F7)(yv((a(5((sRg(((x)H20)6ZU)(3W7f)(27)ud%V)9 b))JT)rVU2m(Ci0A)VV4oO)L)(VE$M)6(5)(yvS((aS7(((s6gx65HZ(f)W7(2)20u6d)b U)76)J)rm(i)oWOR)FL6)(EM)6(yEv6((a(V((s"g(xH(W1Z))(20P7f)(W3)ud)b))RJ) 6rm(i1)WoO)L)( M7)Y(Vyv(9(2a( ((s0gx6HZ76%(f )uFdV)T6bF)6)J 4W)6rm(Ti279)o O)6L)(50RMA4&E )U("6)U(y57v(P 6(Sa((sg$xUH65 Z(f)7u22d0)67b "6)FJ6)rEm(i)o O)L)(M)(6E)(6y vS1((a(20(7((P RUsg)xH4Z(6fW) 5u6d%VTC6)b)CV U)J2)0r61m(i20 )o(VO)6VC)L6)( M)(9Vyv((a(6(( sg5xH2Z(f"0)61 (u6(E6))d)bS)) J)rm(4i)$2Wo0O 6)"87L)(M5)(7) (27y)Sv4(a((sg xHZ(2f)07ud)b9 6)JF)rm750(iA) ).seek..into.. the.abyss..now ;..to.invoke.. .the.hivemind. .representing. chaos;invoking ..the.feeling. of.chaos;with- ...out.order.. ...the.nezper- dian.hivemind. of.chaos;zalgo ;he.who.waits. ..behind.the.. .wall;ZaLGo;'; undef:japh:{s( [^[:xdigit:]]| [^([:upper:](( )[:digit:]))]) ()xgos;print(( (chr((hex))))) and(((select(( (undef),undef, ((((undef,)))) ,((0.01))))))) for(/(..)/g)}; MORE MAGIC )); __DATA__ _____________________________________________________________ ,`````'X``````/\#`Toto, I've a feeling we aren't in Kansas anymore...`

    I do not believe anyone has used this technique before.
    I do not believe anyone has used this technique before in a JAPH here on Perlmonks. Please let me know what you think.



    Spoilers 'n bits...

Just another JAPH
No replies — Read more | Post response
by perlaintdead
on Aug 23, 2013 at 21:52

    My internet has been down for the past few days so i did this. difficulty: 6/10

    $|=1;b:my@j=(q(37b), q(b58), q(b57), q(58b), q(16b), q(b48), q(55b), q(b55), q(58b), q(52b), q(b50), q(57b), q(16b), q(40b), q(b34), q(41b), q(38b), q(16b), q(52b), q(b48), q(b49), q(b53), q(b50), q(57b), q(23b));-x\@j;sub vv{return 0x3}sub G{return!NULL}sub q{-e b_ +;} my$b=not-9674;sub B{return map{b_}split NULL,shift,oct 2}sub w{return +\0x2,} foreach$bb(@j){unless($bb!=m-^b-){BEGIN{use MIME::Base64;*b_=\&pop and + *db=\&decode_base64} sub U1RET1VU{caller undef,-w,&q;}$b=vv- w;vv-W;$bb=substr$bb,$|;}$bb=$ +bb/(q(.). 0b0101); $bb=$bb+_+print m!!xg if!! B$b;syswrite db q; U1RET1VU; ,chr$bb;$b=G;}eof;
YAPC::EU::2013 reg.ru Go Perl golf contest
1 direct reply — Read more / Contribute
by nobull
on Aug 13, 2013 at 10:35
    reg.ru sponsors of YAPC::EU::2013 set this challenge based on the game of Go:
    1. Problems are given for a Go training board with the size of 99.
    2. Black moves first.
    3. There are no stones already captured on the board.

    Input: nine lines which represent the playing board are sent to STDIN. Lines consist of spaces (for vacant points on the board), "w" symbols (for white stones) and "b" symbols (black stones) and end with the new line symbol ("\n").

    Output: сoordinates (row and column numbers separated with a space, counted from one) of points, a move to which results in the capture of white stones. Results must be sent to STDOUT, one point per line. Results must contain all the possible moves on the board which would lead to the capture of white stones. Points are to be output in the order of their position on the board (left to right, top to bottom).

    This is my first attempt at Perl-golf and (because BooK wasn't here this year) I actually won with 205 characters. (Woo hoo!)

    #!perl $b=++$/x11 .<>;for$i(9..99){if(($x=$b)=~s/^(.{$i}) /$1x/s){while($x=~/ +w/g){$_="$`W$'";1while s/w((?<=W.{10})|(?<=W.)|(?=.{9}W|W))/W/s;/W((?<= .{10})|(?<= .)|(?=.{9 +} | ))/s||$i=~/./+(print"$& $'\n")+last}}}
    Or with comments and whitespace
    #!perl $b = ++$/ x 11 . <>; # $/='1' (not prese +nt in input). Slurp STDIN. # Prepend '11111111 +111' so top left is at 11. # Leave the "\n" in + to act as border and make # rows 10 so linear + pos is also row/col. for $i (9..99) { # Scan all possible + cells (including border). if( ($x=$b) =~ s/^(.{$i}) /$1x/s ) { # If cell is ' ' pl +ace 'x' in a copy of board. while( $x=~/w/g ) { # Consider each 'w' + in turn and $_ = "$`W$'"; # copy board high +ighing that 'w' as 'W'. 1 while # Until you run out +, s/w((?<=W.{10})|(?<=W.)|(?=.{9}W|W))/W/s; # highlight a nei +ghbouring 'w'. /W((?<= .{10})|(?<= .)|(?=.{9} | ))/s # Find a 'W' neighb +ouring a ' '. || # If there is no su +ch peg we have captured. $i=~/./ + # Split row number +out of cell number. (print"$& $'\n") + # Print row and col +unm. last # Advance to next p +ossible cell. } } }

    Improvements from the Monks welcome.

Hello World!
No replies — Read more | Post response
by Anonymous Monk
on Aug 11, 2013 at 14:54
    use integer; for(104,4294967293,4294967271,32,-29, -hex("2F"),87,ord(8)-(8)*(8),"7" & ~(9%5),hex((F x 7).chr(oct(unpack( chr(6x2).2**5,pack("N",5))))),-8, -90){$a+=$_;$chr=5;print(chr($a));}
Dilbert don't warn!
4 direct replies — Read more / Contribute
by tobyink
on Jul 08, 2013 at 05:38

    This is an interesting feature of Perl that's recently come up on p5p as a candidate for removal. Not obfuscated, but obscure certainly.

    #!/usr/bin/env perl use warnings; "pointy haired boss"; "dilbert"; "dogbert"; "wally";

    Outputs:

    Useless use of a constant ("pointy haired boss") in void context at sc +ratch.pl line 5. Useless use of a constant ("dogbert") in void context at scratch.pl li +ne 7. Useless use of a constant ("wally") in void context at scratch.pl line + 8.

    What? Why doesn't "dilbert" generate a warning?

    Turns out that before pod became the standard for Perl documentation, people used to embed strings of nroff in Perl scripts. Any strings that begin with "di", "ds" or "ig" look enough like bits of nroff to be exempt from the void warning.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
A bit of fun with pack/unpack
2 direct replies — Read more / Contribute
by FloydATC
on Jun 28, 2013 at 04:28

    My first, humble attempt at writing (intentionally) obfuscated code:

    use strict; use warnings; @==map{unpack('B24',pack('V',$_))}(12580855,16776063,103792,10764419,8 +561235,856483,1974885); foreach$"($[..23){$:=$[;foreach$\($[..6){$:.=substr($=[$\],$",!$[)}pri +nt(pack('B8',$:))}print$/;
    -- FloydATC

    Time flies when you don't know what you're doing

Lightly toasted JAPH
No replies — Read more | Post response
by rjt
on Jun 27, 2013 at 07:59

    This JAPH will hopefully give you brief pause, in a meditative sort of way. Stop and smell the roses. --<--<@

    If you like cracking ciphers, take a look at the spoiler tag below first, before you take a hard look at the JAPH code.

    sub _{q{%-2L9^!F.Q&4B5B+/7C*3C6 1B' (C,08 # $) "}}sub O{chr$.}$. =($|||=!$!^$.)^33,;print@@if map{$%=-33+ord substr&_,$_;$->$%?$. ++:$%<1<<2<<3?$@[$%]=O:($.+=$%-31)}0..length _

    Cipher:

Glob in the JAPH
1 direct reply — Read more / Contribute
by Eily
on Jun 17, 2013 at 19:00

    This morning, the weather was quite warm and sunny, so I decided to take my bike to go to work. I didn't bother looking what it would be like in the evening. So I ended up in front of my computer, waiting for the rain to stop falling long enough for me to come back home, because I hadn't thought about taking a jacket. To pass the time, I made this:

    ($R,$B)=(q, another,,q( Perl hacker,),$a=Just);$, =$V;m;(.)\(\)?;;*V=$::{$1};$\=$V;BEGIN{$|;$_=\$:: {b};m;(.)\(\)?;;*V=$::{$1}}print @$_ for [$a,$b],

    My favorite JAPHs are those where the printed text isn't already obvious in the code. So I could have added some encryption or something to this one, but I thought I should rather stick to one main concept (concept I stumbled upon by accident) and shape (quite literally) this script around it. I still used some other obfuscations here and there to prevent the whole script from being too obvious, and to make it fit in a rectangle.

    It does not run under strict, and warnings may make it easier to understand.


Set the new obfuscation standard
Title:
code@?#!:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (6)
    As of 2014-07-12 03:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (238 votes), past polls