Hi there! So I did some reading and have some queries:

(1) Why is the Schwartzian transform read from bottom to top? Since in procedural programming it's usually top to bottom. Reading the Wikipedia article it makes sense however curious as to the behavior of this method.


(2)Could you please explain the expression used in map{}? { my $stat = stat $_; [ $_, $stat->mtime ] } I understand that a scalar variable called $stat has been defined to the 'default variable' $_. My understanding is that when map() is run (the map on the bottom) it evaluates the expression within {} for each element in @fileNames and stores it in the default variable? So would this mean that each time an element is passed the default variable changes?

(3) Further to (2), I understand that "$stat->mtime" is getting the last modified time since epoch for each value of $stat, my understanding is that each time the next element from the array is passed the mtime for that particular $stat is obtained. So what's the meaning of  [ $_, $stat->mtime ]. Since there's a comma separating the two.

(4) The semicolon in { my $stat = stat $_; [ $_, $stat->mtime ] } is separating the two statements within this single expression. Is that correct?

(5) I understand that in sort { $b->[1] <=> $a->[1] } a descending numeric sort is being performed. However what I don't get is the [1] $b and $a both share. Also what's the relationship between $b and $a? I found an example of this type of sort on the net however it did not explain why $b and $a are used. Do they simply represent two different locations in a list?

(6)The  map $_->[0] does not appear to follow the format map({expression}, list). How is this different to the standard map function?

Thanks for your help! Sorry for these questions just clarifying my doubts.

In reply to Re^2: Delete all but the most recent backup file by jagexCoder
in thread Delete all but the most recent backup file by jagexCoder

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.