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
eval JAPH
4 direct replies — Read more / Contribute
by kyle
on Apr 23, 2008 at 16:24
srand & rand to encode strings
1 direct reply — Read more / Contribute
by elmex
on Apr 18, 2008 at 10:11

    The last obfuscation w.r.t. fft got me inspired, so I spent some of my CPU time to do this:

    print join (' ', map { srand ($_->[0]); my $l; for (1..$_->[1]) { $l = ''; $l .= chr (int (rand (58))+65) for 1..6; } substr ($l, 0, $_->[0] < 1024 ? 4 : 6) } [346, 5305], [59235, 9374], [512, 2698], [104315, 5127]), "\n";

    I hope it works everywhere, as I'm not sure whether srand&rand have the same algo everywhere.

fft japh
1 direct reply — Read more / Contribute
by jdporter
on Apr 17, 2008 at 11:53

    Based on tekniq discussed in encode a string into a complicated-looking trigonometric function

    print chr(91.540 + 0.765*cos(0.251*$_) + 3.886*sin(0.251*$_) - 1.470*cos(0.503*$_) - 7.599*sin(0.503*$_) + 4.480*cos(0.754*$_) - 1.094*sin(0.754*$_) - 11.495*cos(1.005*$_) + 22.147*sin(1.005*$_) + 1.792*cos(1.257*$_) + 8.512*sin(1.257*$_) - 20.389*cos(1.508*$_) - 1.167*sin(1.508*$_) - 1.011*cos(1.759*$_) + 2.549*sin(1.759*$_) + 2.712*cos(2.011*$_) + 3.110*sin(2.011*$_) + 6.179*cos(2.262*$_) - 2.177*sin(2.262*$_) - 2.232*cos(2.513*$_) + 16.511*sin(2.513*$_) + 5.236*cos(2.765*$_) + 1.260*sin(2.765*$_) - 1.607*cos(3.016*$_) + 4.017*sin(3.016*$_) )for 0..24;

    Update: Small change, props to ambrus.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
Wall of Text
1 direct reply — Read more / Contribute
by kyle
on Apr 10, 2008 at 12:39

    This is another along a similar vein to my last obfuscation, Brute force JAPH. Here again, crypt is used to generate the output, so deciphering all this is not straight-forward. This also means this may be a bit platform dependent (i.e., it depends on what your crypt() does).

    The format of the text comes from the Unix banner program.

    I'll explain the workings of this in the spoiler.

encryption golf (one time pad)
2 direct replies — Read more / Contribute
by mr_mischief
on Mar 17, 2008 at 03:19
    undef$/;print<>^<>

    In the spirit of the RSA algorithm in the shape of a dolphin, RC5 in six lines of Perl, and similar feats of encryption methods shrunk down to tattoo-worthy sizes, I present a one-time pad cipher golfed to 18 characters.

    The arguments to this should be the pad file (acting as the key) and the message file. You should use a pad file the same length as the message file, or possibly longer. If you use one that's longer, you'll end up with unused pad data after your message.

    Obviously don't use a pad that's shorter than the message. Also, it's called a one-time pad for a reason -- don't reuse the pad file for another message if you want the best security.

    While public-key crypto has advantages there's also a place for shared-key ciphers, and this one should cost a lot less to put on a shirt or into the skin than some others. ;-)

a little japh
No replies — Read more | Post response
by kFish
on Mar 12, 2008 at 12:52
    whelp, after looking on wikipedia i realized someone used basically the same idea and executed it a little more fu :( oh well - here goes!
    #!/usr/bin/perl $_[$.++]=chr for($_=(--$|.$|-$|.$|-$|)-$|---$|---$|- $|)..$_-(-$|-$|.-(-$|-$|-$|-$|-$|)),($|-(-$|).--$|), (--$|.$|-$|);$,=$_[-$|-$|];$\=$_[-$|];print$_[$_=-- $|.$|---$|].$_[$_-=-($|.$|)].$_[$_-=$|-(-$|)].$_[$_- (-$|)],$_[--$|].$_[$_-=-($|---$|-$|-$|-$|-$|)].$_[$_ -=$|---$|---$|-$|].$_[$_-=-$|-$|-$|-$|-$|].$_[$_-=$|. -(-$|-$|)].$_[$_-=-(-$|-$|-$|)].$_[$_-=-($|.$|-(-$|- $|))],$_[$_-=-(-$|-$|)].$_[$_-=$|.$|].$_[$_-=-($|.$| -(-$|-$|))].$_[$_-=-(-$|-$|-$|-$|-$|-$|)],$_[$_-=-( -$|-$|-$|-$|)].$_[$_=--$|].$_[$_-=-($|---(-$|-$|))] .$_[$_-(-$|-$|-$|-$|-$|-$|-$|-$|)].$_[$_-=(-$|-$|)]. $_[$|.($_-(-$|-$|-$|))];
Discover inner truths with PERL
2 direct replies — Read more / Contribute
by Anonymous Monk
on Feb 28, 2008 at 11:40
    $a="tye"; $a++ for 1..165444; print $a;
number sifter
1 direct reply — Read more / Contribute
by ysth
on Feb 21, 2008 at 03:56
    use strict; use warnings; use 5.010; my @n; my @p; sub mk { my $l = shift; no warnings "redefine"; *is=eval 'sub { ' . join(' && ', map('$_[0] % '.$_, grep $_*$_ <= +$n[-1], @p), <<'EOCODE'); ($_[0] <= $l ? (push(@p, $_[0]), say($_[0])) : (unshift(@n, $_[0]), mk($p[-1]**2)) ) } EOCODE } @n=2..(shift//200); mk(2); is(shift @n) while @n;
simple utility method
1 direct reply — Read more / Contribute
by nathaniel.k.smith
on Feb 15, 2008 at 11:46
    sub in_array {return scalar grep{/^@{[pop]}$/}@_}
JAPH with AUTOLOAD
1 direct reply — Read more / Contribute
by sh1tn
on Feb 04, 2008 at 14:20
    #!/usr/bin/perl Just->Another->Perl->Hacker; package Just; INIT { print __PACKAGE__, ' ' } 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.