Okay, I'll give this a shot. My first longish obfu deconstruction:

Here's the obfu, deparsed:

sub a { my(%v) = map({$w[$_], $_;} @w); my $n; sub { $v{$b} <=> $v{$a}; ++$n; } ; } sub _ { my $v = shift @_; sub { $\ = $v; $_ = ''; } ; } @w = sort({&a->($a, $b);} map({_ $_;} split(//, "erl hc\nker.aPust ano +ther J", 0))); foreach $_ (@w) { &$_; print $_; } testfile_orig syntax OK

The first thing that happens is a funny map. A string get split up and passed through map, passing each letter through sub _. This returns a coderef (more on that one later), so that we have at the end of the map an array of coderefs.

Next the array gets "sorted". Funny thing, though -- the sort routine always returns 1. This is where the thing gets further into internals than I can get, but maybe someone can clarify this bit in my stead. It seems to rely on the internals of sort, and how it deals with ordering stuff. It is fooled into always thinking that $a > $b.

Anyway, @w is then iterated over, dereferencing the coderef each time (told you I'd get to it). This sets the output record separator to whichever letter was originally mapped in, then sets $_ to an empty string. The empty string is printed, then the ORS, printing out the whole string.

LAI

__END__

In reply to Re: fun with subroutines by LAI
in thread fun with subroutines by jonadab

Title:
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.