Syntactic Confectionery Delight PerlMonks

### Re^2: Delete all but the most recent backup file

by jagexCoder (Novice)
 on Jan 29, 2013 at 04:34 UTC ( #1015799=note: print w/replies, xml ) Need Help??

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.

Create A New User
Node Status?
node history
Node Type: note [id://1015799]
help
Chatterbox?
 [Corion]: Meh. I need to find myself a better "programming" feed than r/programming (which is just HackerNews reposts and advertisements, very little code). Maybe I should select a list of links that I liked on r/programming and then google for ... [Corion]: ... an aggregator site that also listed (ideally) all of these links once. And maybe also have an exclude list to blacklist some of the most spammy links that the site may have never mentioned at all [marto]: I gave up reading HN at all, and feel much better for it :P [Corion]: Now, how to best automate that Google search ... :-)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-07-24 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I came, I saw, I ...

Results (354 votes). Check out past polls.