Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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??


in reply to Re: Delete all but the most recent backup file
in thread Delete all but the most recent backup file

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.


Comment on Re^2: Delete all but the most recent backup file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015799]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-12-25 13:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls