Well, I can't comment on the meaningfullness of the name as you've removed it, but the intent of the code is clear. Even if the formatting is a bit awkward. (operators at the end of the lines? Come on! This ain't Ruby ... you don't have to hint the compiler that we are not done with the statement yet!)

This, in my humble opinion, rather readable snippet of code is supposed to be used by the sort() routine and specifies that the AoA is to be sorted by 3rd, 2nd, 1st, 0th and 4th columns in this order of importance. You might want to use constants instead of the numbers to specify the columns, but that's about the best you can do.

Unless of course you want to factor out the indices and use something like

sub SUB_NAME { for (3,2,1,0,4) { # sort by the specified columns my $res = ($a->[$_] <=> $b->[$_]) and return $res; } }
which would definitely need some explanation. Other than that whenever you see <=> or cmp, especially if comparing (some part of) $a and $b, think "sort".

Update: Oops. Good catch merlyn, thanks. A reminder to test the code I post here.


In reply to Re:Why programming is so much more than writing code by Jenda
in thread Why programming is so much more than writing code by swngnmonk

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.