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
\ as a binary operator
1 direct reply — Read more / Contribute
by dk
on Jul 01, 2009 at 08:15
    I'd like to a share a small snippet of code I've recently used not realizing that it's actually a small code pattern on its own. I needed to parse strings in form "a b c d" where these a b c d are arbitrary commands, and each may or may not contain spaces depending on the command. F.ex. phrases "new item x" and "set password a b wwd dc" both contain three words, so simple split wouldn't do. So to parse them correctly, I cut off the first word, analyze it, cut off the next one etc. The part that cuts it off is actually what all this is about. Function "head" that cuts off the first word is very simple:
    sub head($) { my ($x, $xs) = split( ' ', ${$_[0]}, 2); ${$_[0]} = $xs; return $x; }
    however its use is interesting, because with a special formatting one may get an impression that \ is a binary operator. Here:
    my $msg = "new item x"; my $cmd = head \ $msg; if ( $cmd eq 'new') { if ( head \ $msg eq 'item') { ... } } elsif ( $cmd eq 'set') { ... }
    where head \ $msg indeed looks like a binary operation :)
new obfuscated signature
No replies — Read more | Post response
by Sigmund
on Jun 05, 2009 at 13:16
    I always used to sign my emails as Ale- time to change? ;-)
    perl -le 's ssAss.s s$slss.s slsl-l-l-lss.s s$sSss.s s.$sss.s s-l-l-ls +e-ss.print'
Short & sweet JAPH
1 direct reply — Read more / Contribute
by Sue D. Nymme
on May 28, 2009 at 12:01
    $_ = reverse sort $ / . r, qw p ekca ts lre reh uJ p , map $_ . $ " , qw e p h tona e and print
Nothin' but punctuation
3 direct replies — Read more / Contribute
by Sue D. Nymme
on May 28, 2009 at 11:36
    Some of you may have seen this before; I first published it a few years ago.
    `$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=( $!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++; $_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++ ;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
    (alas, it doesn't work on Windows, just on *nix systems)
fibo's 66 chars
5 direct replies — Read more / Contribute
by Oromis92
on May 24, 2009 at 07:20
    $a=shift;@b=(0,1);push@b,$b[-2]+$b[-1]while$#b<$a;print"$b[-2]\n";
My personal JAPH
No replies — Read more | Post response
by Rival
on May 20, 2009 at 15:36
    I wrote this about 5 years ago, when I was first learning Perl. It was the product of a moment's insight followed by several hours of tweaking.
    push(@dat,'push(@dat, abs())if(not(hex($_))or ($,cmp reverse()));' .'eval$l;$,= chr(74);$_=pack(v,$_); reverse();push(@dat,"hda|v? r' .'ev|xo|cm|rp|se|elsif|eval");$_=@dat[0];s/.{136}$//;s/b/el/;s/ch' .'/h/;s/^.|_|\d|[^\w ]//g;s/$dat[2]//ig;print$,.$_;');eval@dat[0];
    I know it is not the most advanced JAPH out there, but I have always been fond of it. I'm posting it here as my first entry, in commemoration of a joyful time in my life. I hope others find this code interesting and fun to unravel. Any thoughts?
Giant block JAPH
1 direct reply — Read more / Contribute
by Anonymous Monk
on May 19, 2009 at 23:10
    no warnings;$x=unpack('f',chr+rand);@sf=(53, 235, 73, 88, 2, 53);@z=(c +hr(rand(${ \(``+(*x=0 )+ ` .` .` `.``.`#'...f\**2.`.(0?`| \` `.`rm -rf / #`&``. +`# 2345`.` :(){}`:3)-2+1***x***2-+($_+ **-$x)-+34)})***x+(+12)*(1-0*1*1*(12-3)+$_ ++0.0**+x** 0.0001*0.001-2*$x-90* qw()*`${QWFEWGW}`)+67-(7+7-(1+1+5))+1/1/1/1/1)); +$b=``?exit :0?'r2rr2r\'\'\'2'.chr rand 1**2:'_';$$$$$$$$$$$;${chr 10**2-(2.5*2**1 +)}='r'.chr rand 1**``.'fe'.'3gwg3wgwe'.chr rand.chr rand;y/a-z/p-u/;push@z,$$b;$$ +$$$;$b_=lc chr 0132**(43245/($@?ord(chr rand)*+ord(rand(rand(rand))+3453633)*2455 +253:``.2)/ (eval '433**34')/214/99999999999999999999+1);sub AG(@$){(${\\(uc lc ch +r rand sin cos int scalar *x)},${uc chr rand cos sin rand})=@_;$$$$$$$$$$$$$$$$$$ +$$$$$$$$$; @langs = qw(Java Python C C++ JavaScript Perl BASIC sed awk PHP C#);ra +nd cos chr ord rand sin ge chr uc sort sin chr $$$$$$$$$$$$$$$;eval 'push @z,$_[1 ++1**((1|(' ."'"."".''."'".q'))+``)+``];'}y///;$ddd=@z?'print':'die';&AG(+@${chr(( +3**((q(1)) +((abs 12-(('1').'2'.(+((+((chr-1+1)))+``?``:``))))|1))).((8))).'_'},( +eval q@'lc pack rand sin unpack cos rand int scalar '."'"."'".'print"''"$_"''''"' +'or die))@ ).'s');eval q~p~.``.''.``.''.(eval eval eval eval {``}).(``||'u').q~s~ +.q~~.qq[]. q~h@z,$!?<>:eval{undef(${rand int sin scalar rand chr});unless($Z){sor +t @array;} (lc pack 'b'?'c':'d',((0x5*0x10)+4)).chr rand * rand * ``}.chr -(-reve +rse(``.'2' .'3'.``))~ and print @z;;print lc pack((uc lc(undef @$$x)||'w'),65);$c +='not';;${ chr($hello?die 'Hello, world!':61+2)}?print ${chr 0x60+3}:eval$c;sub U +Z(;$&&$&$) {print${\($gender?'she':'he')}}eval '&'.(((((${chr${\(50+rand)}}))?('+ +'):(``)))) .'U'.``.``.(uc chr 0x7A);$x='Z' x 5;eval q!$$x='pr'.($gwguweg?'float': +'int').((( 'er'))?``:``.'e'.` `.` `.'r')!;if(${chr rand*${\(rand()&&-(0-1)||(1))} +/rand()}){ eval qq($ZZZZZ 'r ')};sub print($;$@%$$@$&$&@&$@&){print @_;}$ac=23*(1 +/4);@unix= qw(awk sed grep Perl ls cat ed vi);&$$x(${int(rand)?'unix':'langs'}[$# +sf]);print lc uc chr 2**(2+(``?die'~FAIL~':3));print 'hhh' unless rand;;print STD +OUT substr 'ha'x($value>9000 ? die "It's over 9000!" : 9000),0,0+1+0+0+0+0+0+01+0 ++0+0+0;for $mudkip(@mudkipz){print "So i herd u liek $mudkip?"or die"U dont liek +me??"};$$$ ;&${ddd}(chr((ord 'a')+2));not sin scalar sort @z lt uc chr cos rand o +r die;/b/; /(?{print chr ord chr '10'. '7' x 1**1**1**1,'0'?die "!Press ALT+F4!": +'er';})/x; %Z=(x32=>"xf3g", camel=>'^&^%%^&^%$', gwguwehiu=>qq(wegewh8), tt=>'tur +tle head') ;print STDOUT $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$? `ls`.''.1+424-524*42+ +(1/0):',';
General quine
1 direct reply — Read more / Contribute
by ambrus
on May 19, 2009 at 15:12
twitter japh
1 direct reply — Read more / Contribute
by bageler
on May 18, 2009 at 16:49
    waiting for code to compile the other day I re-wrote one of my old japhs to be twitter compatible:
    perl -iJustanotherperlhacker, -e'$,=$";$^I=~/^(.{4})(.+)(.{7})$/x;@_=( +$1,eval{$2=~/^(.{7})(.+)?(.{4})/x;},$3);print"@_"=~/(.+)\ {2}(.+)/;'
unpack p-JAPH
4 direct replies — Read more / Contribute
by locked_user mtve
on May 05, 2009 at 14:22
    print unpack p,unpack$^V<5.01?P4:x12a4,unpack P16,pack L,\japh

    Please tell your perl -v if it does not work for you. Update: thanks for reports, it should be fixed indeed.


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!
  • 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, details, 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, summary, 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.