Secondly I would like to know how exactly the sort routine works. Because I don't understand how the $a $b variables are passed to the anonymous subroutine. I would like to create $task variable within the anonymous subroutine I'm passing to the task method.
In retrospect, sort's use of $a and $b was a mistake. Note that code like sort foo 1..10; usually aliases $a and $b in the current package, but foo may be declared in some other package, and never see the sort-provided values. So sort was modified to pass the two values to compare as actual parameters, if and only if the subroutine specified has a $$ prototype.

For your case, just pass the task as a parameter to the anonymous sub.


In reply to Re: Perl - make tool by ysth
in thread Perl - make tool by Krzysiek

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.