Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
No such thing as a small change.
 
PerlMonks

Obfuscated code

 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

( #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
Keyboard Trouble
on Jul 03, 2010 at 02:34
1 direct reply by Xiong
    I splashed just a tiny bit of water into my kbd and now the 'one' key doesn't work. (This is not a joke{bang}) So, I've been avoiding the chars it used to produce.
    $l = 2/77; $| = 2; @F = ( '000*000*000*0*000*00*', '0*00*00*0*0*00*00*00*0*0*', '00*0*00*00*00*0000*00*', ); for (@F) { $. = 0; while ($g = length) { select $i, $j, $k, $l; $s = $_; $s =~ s/0/ /g; $m = unpack 'b*', pack 'v', $.; $m =~ s/0/ /g; $m =~ s/\d/*/g; print "\r", ' 'x$g, $s, $m, ' 'x2; $. += chop() ? 2/2 : $.; }; print "\n"; };
    - the lyf so short, the craft so long to lerne -
Great Idea!
on May 12, 2010 at 08:13
0 direct replies by joecamel
    ! ! ! ! ! ! ! i ;$_=join( q!!=>map{$!=$!& 0;map{s$![^\]! =s!! \$x-Y\\[@!]!Y=$! =$x ;$!+=s$[q!=>\$x-Y= [@! ]$!={$g}@$_;$g=i&& q!! . chr ($! +0x3E)}([\\$!=>{!! !$! =>! chr , [!$!]}]=>[\$!=>\$!=>\$! =>[!$!]]=>[\$!=>\$!=> {$!=>[$!]}=>{!$!=>[ $!]}]=>[\\$!=>{$! =>[Y]}]=>[\$!=> {$!=>[!$!]}=> \\!$!]=>[ \\$!])) ; print=> ! ! print=> ! ! print=> ! print=> print=> print
turn it upside-down
on Apr 20, 2010 at 13:21
4 direct replies by AutomateWithPerl
    s/\:\(/\:\)/g;
use perl;
on Feb 25, 2010 at 15:00
0 direct replies by shmem
    print q.use..$",sub{use:perl,@_}->(q);)),^@^,q;or die;
My e-mail signature JAPH
on Feb 23, 2010 at 15:24
0 direct replies by joaocoutinho
    perl -E '@O=("\x61\x6e\x6f\x74\x68\x65\x72","\x50\x65\x72\x6c","\x68\x61\x63\x6b\x65\x72\x2c\xa");$J0="\x4a\x75\x73\x74\x20";say"$J0@O"'
Decimal Gray Code in 31 chars
on Jan 18, 2010 at 17:14
2 direct replies by Oromis92
    print(($_^$_>>1).$/)for(0..pop)

    simplest as possible

Yuletide Greetings!
on Dec 24, 2009 at 17:04
0 direct replies by je44ery
    $t = int rand(14) + 6; $t = $t % 2 ? $t + 1 : $t; for $l (1..$t) { print ' ' x ((int(($t + 1) / 2 )) + 1) . "*\n" if $l == 1; print ' ' x (int(($t + 1) / 2 )) . '/' . (int rand(2) ? "#" : '&') . "\\\n" if $l == 2 ; print ' ' x ((($t + 1) - ($l + ($l % 2 ? 0 : 1))) / 2) . '/' . (int rand(2) ? "#" : '&') x ($l + ($l % 2 ? 0 : 1)) . "\\\n" if $l >= 3 ; } print '^' x ($t + 3) . "\n"; print ' ' x ($t / 2) . '|H|' . "\n";
Xmas Msg (just for linux)
on Dec 23, 2009 at 14:40
0 direct replies by smokemachine
    perl -e'*MERRY=*\;*XMAS=*/;' -F: -nae'$,=join q,,,map{chr$_+@{[(1)x un +pack q C\CC,q q \q \q q]}}q 1007769828289001 =~/.{2}/g;BEGIN{*SANTA = + *ARGV}$MERRY=$XMAS;print$F[0],join q,,,map{chr}q;0991041141051151161 +09097115;=~/(.{3})/g;BEGIN{push@SANTA,join q,,,map{chr}q 304710111609 +90471120971151151191003 =~/(.{3})/g}'
Functional Composition
on Dec 17, 2009 at 15:41
2 direct replies by billh

    This isn't really obfuscation, it's even vaguely useful, but see if you can figure out what Pipes.pm must be doing, given that this prints o-l-l-e-H

    use strict; use warnings; use Pipes; print "hello" | fn { ucfirst($_[0]) } | fn { [ split('', $_[0]) ] } | fn { [ reverse(@{$_[0]}) ] } | fn { join('-', @{$_[0]}) } | fn { $_[0] . "\n" };
    Bill H
    perl -e 'print sub { "Hello @{[shift->()]}!\n" }->(sub{"World"})'
Doing it with command line switches
on Dec 10, 2009 at 08:43
3 direct replies by JavaFan
    On the chatterbox, PhilHibbs asked Does anyone know how to make ls produce a comma-separated list, or have a perl one-liner to do it?

    Here's a solution that does it all with command line switches:

    ls -1|perl -054lp012e1
    I leave it as an exercise to the reader to figure out how it works.
 (1-10) of 300 Next entries--> 

  • 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
  • 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.
  • Login:
    Password
    remember me
    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 scrutinizing the Monastery: (13)
    GrandFather
    atcroft
    mr_mischief
    CardinalNumber
    herveus
    MidLifeXis
    thunders
    ssandv
    djp
    AndyZaft
    Neighbour
    im2
    BourneID
    As of 2010-09-06 03:18 GMT
    Sections?
    Seekers of Perl Wisdom
    Cool Uses for Perl
    Meditations
    PerlMonks Discussion
    Categorized Q&A
    Tutorials
    Obfuscated Code
    Perl Poetry
    Perl News
    See About the sections of PerlMonks
    Information?
    PerlMonks FAQ
    Guide to the Monastery
    What's New at PerlMonks
    Voting/Experience System
    Tutorials
    Reviews
    Library
    Perl FAQs
    Other Info Sources
    Find Nodes?
    Nodes You Wrote
    Super Search
    List Nodes By Users
    Newest Nodes
    Recently Active Threads
    Selected Best Nodes
    Best Nodes
    Worst Nodes
    Saints in our Book
    Leftovers?
    The St. Larry Wall Shrine
    Offering Plate
    Awards
    Craft
    Snippets Section
    Code Catacombs
    Quests
    Editor Requests
    Buy PerlMonks Gear
    PerlMonks Merchandise
    Planet Perl
    Perlsphere
    Use Perl
    Perl.com
    Perl 5 Wiki
    Perl Jobs
    Perl Mongers
    Perl Directory
    Perl documentation
    CPAN
    Random Node
    Voting Booth?

    My favourite poll on PerlMonks is ...

    Your first Perl Book - the first one ever
    Average number of caffeinated beverages per work day - the poll with the highest participation
    My Thoughts on the New Voting/Experience System - the poll with the fewest votes cast
    When I grow up, I want to be: - one of the polls with the fewest options
    Perl 6 will primarily be: - the first one on Perl6
    When I see a poll - one of the many polls about polls
    this poll ;-)
    yet to come
    none - I hate polls. Bah.
    some other

    Results (95 votes), past polls