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
Pi * Pi = japh?
No replies — Read more | Post response
by hbm
on Feb 05, 2009 at 16:38
    use strict; my($s, $pin, @IP); use constant PI => 3.14159265; $s = (int(PI) * int(PI)); s++; print 'PI SQUARED=' . (PI*PI); ++y,($pin='tr'; @IP=<*>),\0,d; die[uc^"\010${s}0%)sed)"]->[0]
Drunken words
2 direct replies — Read more / Contribute
by buetow
on Jan 29, 2009 at 18:24
    Hello! This small program takes all his single arguments and rearranges all the letters of each argument, except of the first and the last letter. This way, all sentences sound like drunken. Example:
    perl drunken.pl I think it is funny that people still understand this +sentence I tnihk it is fnnuy taht pploee slitl usnretadnd tihs scnetnee
    And here is the program:
    use strict; $| = 1; for (@ARGV) { s/(.?)(.*)(.\W*)$/$2/; print $1; my ( $l, @w ) = ( $3, reverse split // ); print splice @w, rand $#w - 1, 1 while $#w + 1; print "$l "; } print "\n";
    Who has a better solution? Don't ask for a sense ;)

    Update: Waht deos bteter mnae? Wlle, wt'ahs better for yuo. Mbyae snoenoe lekis to hvae lses cedo, the nxet one lekis to hvae it mroe ousacetfbd.

    Update 2: I wrote a small plugin for Irssi which makes you write like a drunken man ;)

    Update 3: Changed the link of the plugin into a link which will never be obsolet.

    Update 3b: Sorry, changed the link again :( But it should stay now this way :)

    Paul C. Buetow
Brute-force JAPH
1 direct reply — Read more / Contribute
by jh-
on Jan 27, 2009 at 17:28

    Hi all,
    This is the first JAPH I've ever written. It's simple, but (AFAIK) has an original idea.

    use Time::HiRes 'usleep';++$|;$s='rekcah lreP rehtona tsuJ';@v= (65..90,97..122,32);do{do{print$_=sprintf'%c',$v[rand@v];usleep 2000;print"\b"}while$_ ne substr$s,-1;chop$s;print}while$s

    Update: An indented and commented version with whitespaces

I say "JAPH!"
1 direct reply — Read more / Contribute
by hbm
on Jan 25, 2009 at 23:33
    I often wondered why anyone would spend time on these silly things. But they're fun!
    use strict; use warnings; $_=[(25.5*6<<q{9}.1)=~m+(..)+go],//moss; --$.for(1..((5<6).0));($/=>$.)=(-$.,$.); $.*=@{_}=map{$.+=$/;$_+$.}grep{$_%2}@$_; push@_,map{if(!int){$.+=$.}else{$.+=$/}; $_+$.}grep{($_+1)%2}@$_;die map{chr}@{_} [eval join(q{,},2,1,4,3,0)]=>$/||\$\<<1;

    Update: With whitespace and comments:

No truth, no beauty.
No replies — Read more | Post response
by kyle
on Jan 24, 2009 at 16:31

    This has to be in a file to run correctly, and it has to be the entire contents of the file (no #!perl line). It won't work if it's reformatted.

    open+0 and local $/; $ms = <0> and close 0; $false = q[OlD|OIDlDOIOl!Di|] =~ /[1|0]/; my $fa1se = eval 'BEGIN{ 1/0 }' if $false; ($false||rand)&&split / /, $ms; $truth = $beauty = '' =~ //; if ( $truth and $beauty ) { split' ', $ms; $ls[ $false+=8 ] = shift @_ while @_; map { $_ = 054 + length } @ls; # This part is important!!! 23 while s/(.{0,8})(..)/crypt$1,$2/ge; } my $O; $ls[ $false++ ] = $_ for @_ ;s{.}{ord($&)%0x0a}ego for grep $_, @ls; ( 598306+679527+682489!=+585085 ); $O = join qq,, , map { ( $_ )? chr( 0b1001010+length ) : defined() ? qq- - : 'J' } @ls; $_ = chr 0xdeadbeef % +255 for @ls; $O=$0 if ($truth); $beauty && {redo};exit !print qq/$O,\n/;

    This is yet another encoding trick, probably one that's been done many times before, but here's my crack at it. I'll explain the workings in the spoiler.

Inauguration Day
No replies — Read more | Post response
by hbm
on Jan 21, 2009 at 12:18

    The sole reason for my dabbling here is the length of names of the outgoing and incoming teams. I'm sure the sages will see right through my lame masking of characters, but hopefully there are at least a couple surprises.

    use strict; use warnings; use constant ist => q{3}x2; my @eye = "7966668565836672654747677772736968787889" =~ m|(..)|g; ${_}||= # Back to our $whitehouse='BUSH/CHENEY' # Texas & .$/||\1; # Wyoming foreach my $W ( map { s|(\d+)|chr($1)|eg; $_ } map { "\LS!". join( chr(ist), pop(@eye), pop(@eye), $!) } (2001..2009)=>undef){ $!=~eval $W} die((!$!)?uc:$::)

    Update: With whitespace and comments:

The Emperor's New Clothes
11 direct replies — Read more / Contribute
by Anonymous Monk
on Jan 15, 2009 at 18:44
    Below is the shortest perl code ever written. If you cannot see it then you are a fool: Can you see it?
LWP japh
No replies — Read more | Post response
by setebos
on Jan 14, 2009 at 14:23
    $_=($_=LWP::UserAgent->new->request(HTTP::Request->new (GET,"http://www.perlmonks.org/?node_id=735555"))->content) ? join(' ', split(/\W+\w+?\W/, (/.+(just.+?hacker).+/si)[0])) : $;; print; use LWP::UserAgent

    $_=($_=LWP::UserAgent->new,$_->agent("Mozilla/5.0"), $_=$_->request(HTTP::Request->new (GET,"http://www.google.com/search?q=japh"))->content) ? join(q/ /, split(q{_}, (/(just.+?hacker)/si)[0])) : $;; print; use LWP::UserAgent
Missing Script Japh
No replies — Read more | Post response
by liverpole
on Jan 11, 2009 at 16:09
    It's hard to believe it's been over a year since I submitted an obfuscation.  Just a simple one to get my feet wet again...

    (Can you find the hidden smiley?)

    s++ uc`$^X -x "$0" 2>&1`+e;y=O =#=d&&die$_^q*$V#1r-=,&!5&fs0<(i&(-;0&*

    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
old and ordinary
1 direct reply — Read more / Contribute
by setebos
on Jan 11, 2009 at 15:49
    JAPH->Just->Another->Perl->Hacker; package JAPH; sub AUTOLOAD { bless [print+($AUTOLOAD=~/::(.+)/)[0], q/ /] } sub DESTROY {}

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.