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
ref and JAPH
1 direct reply — Read more / Contribute
by setebos
on Jan 09, 2009 at 13:08
    ($\={})=~s/(?<=.).+//&&print+(q/J/,\//=~ /..(\S)/&&$1.$2.($^X=~/.+\/(.)/&&uc($1)))
    Thanks to ikegami (the "/" separator is not always the case with $^X):
    ($\={})=~s/(?<=.).+//&&print+(q/J/,\//=~ /..(\S)/&&$1.$2.($^X=~/\W(.)\w+\.?\w*?$/&&uc($1)))
package JAPH
3 direct replies — Read more / Contribute
by setebos
on Jan 09, 2009 at 09:35
    {$}=(scalar(%::)=~/\/(\d+)/&&$1)}{package JAPH} print(($_)=[%::]->[$_]=~/(\w+)/,$/)for+($}-2..$}-2)
meow for buubot
4 direct replies — Read more / Contribute
by jagh
on Dec 20, 2008 at 02:04
    This is, of course(!) only meant for a buubot to 'eval: ', due to the wonderful things it stuffs into $_. To be honest, the join bit was a happy accident:
    $_=$_->{args}[0],/(meow)/until$\=$1;$\++for 2**8..2**7*(join//,(/(\d)/ +g)[0..4])/22288.2;$\
Japhostrophe
1 direct reply — Read more / Contribute
by ysth
on Dec 14, 2008 at 14:42
JAPH / Perl Rube Goldberg Machine
1 direct reply — Read more / Contribute
by eighty-one
on Dec 10, 2008 at 11:51

    This script performs a simple task in a needlessly complex manner.

    I derived this from some work I did out of spite to annoy a Python-programming friend after a discussion about brackets :)

    #!/usr/bin/perl -w use strict; my $japh=<<JAPH [}{{[} {] [] ][[]}] [}[{{] {{ {] {] [[ }{ [] }] {] {]{}]} [} {{ [} {] [] ][ [] }] [}[{{] {{[}[[ [] {}{] ]{ {] [}[{]][} [[[}{} [} [{ {][}{] ][{}]} [} {{ [}{] [] ][ [] }] [} [{ {] {{ {] [}{]{{{] [} {} ]} [} {{ [} {][]][[] }][}[{ {]{{[} [[ [] {} {]]{ {] [} [{ {[ [] }] [] }} [} [{ [] ]{ [][[[}{] {] [} {] ][{}]} [} {{ [}{][] ][[]}] [}[{{] {{ {] {] [[ }{ [] }] {]{]{} ]}[}{{ [}{][] ][ [] }] [} [{ {] {{ [}[[[] {} {] ]{{][} [[ {{ [][[ [}{][] }{ {] [}{]][ {}]}[} {{ [} {] [] ][ [] }] [} [{ {] {{{][}{] {{{][}{} ]} [}{{ [}{][] ][[]} ][ }[ {{ ]{ {[ }[ [[ ]{ }{ ]] {{ ][ }[ {] {[]{[[ ]{ }[ ]]}[][ [[ }{ ]{][}{]][{}]}[}{{[}{][]][[]}][}[{{]{{{]{][[}{[]}]{]{]{}]} JAPH ;my $l=''; my $o='';foreach($japh){chomp; my $len= length($_);for(my $p=0;$p<$len;$p++){ my $b=substr ($_,$p,1); if($b eq ' '){ next;}$o.= b2bin($b);if( length($o) == 8){$l.=pack('B8',$o);$o ='';}}}eval( $l);sub b2bin {my $b = shift; if($b eq '{'){return '00';} elsif($b eq '['){ return '01';} elsif($b eq ']'){return '10';}elsif($b eq '}'){return '11'; }}
Christmas Tree
4 direct replies — Read more / Contribute
by spmlingam
on Dec 03, 2008 at 05:29
    This code will print Christmas tree
    use strict; my ($y,$z);sub tree{my $x=shift;$x=($x>0?-9: $x);$z=( ($z=($x+5))>0?$z:-$z);printf(!$x&&++$y?"\n":$z? $z>$y %3+$y/ 3?" ":$x<-5?"/":"\\":$y?"|":"*");$y-9?tree( ++$x): print(" _|_|_\n")&&print(" \\___/\n");}tree(1);
Advance Happy New Year 2009
No replies — Read more | Post response
by spmlingam
on Dec 02, 2008 at 06:54
    #/usr/bin/perl print pack "H*","416476616e6365204861707079204e6577205965617220323030 +39" ;
Celebrating Indian Independence Day
No replies — Read more | Post response
by dharanivasan
on Dec 01, 2008 at 01:42
    use strict; use warnings; my ($a ,$b,$c) = (10,10,10); for (; ord($a= substr("Love Your Country+ TFy!QJu ROo TNn(ROo)SLq SLq ULo++ UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^+ NBELPeHBFHT}TnALVlBLO+ FAKFCFQHFOQIAIREET+ MSQGCSQOUHATFAJKSbEALGSkMCSl+ OASn+ ^r^r\\tZvYxXy+ T|S~Pn SPm SOn TNn ULo0ULo#ULo-W+ Hq!WFs XDt!YB ",$b+++7,1 )) ;) { for($a = ord($a); $a-- > 64 ; ) { print ( chr(++$c == ord('Z') ? $c = $c/9 : 33^$b&1)); } }
very very simple
No replies — Read more | Post response
by Oromis92
on Nov 29, 2008 at 06:37
    hu, here's my first obfuscated perl code. It's very simple to understand...
    $p=PERL;@p=(24,32,62,35);$P=0 +((1+0)^(0+1))+1;$BP=$P.0;($b .=chr($p[$_]^ord(substr($p,$_ ,$P))))for($P-1..($P+$P)*($P+ $P));$B=substr($b,($P+$P)+$P, $P);chop($b);chop($b);$b.=chr ($p[$P+$P]^ord(substr($p,$P+$ P,$P))).$B.chr($BP);print $b;
Spaceship Zero
1 direct reply — Read more / Contribute
by Orchew
on Nov 09, 2008 at 00:40
    AFAIK there's no perl built-in function to return the sign of a number, something like sgn($x). In some languages I've used $x/abs($x), and but that won't handle zeros.

    I call my solution Spaceship Zero:

    $x<=>0 ;# sgn($x)
    I'm fairly confident that, in perl, that is the shortest possible way to calculate sgn($x).

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.