Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: sorting a file by a date:"YYYY-MM-DD" field with cmp

by MidLifeXis (Monsignor)
on Jun 16, 2015 at 17:46 UTC ( [id://1130654]=note: print w/replies, xml ) Need Help??


in reply to sorting a file by a date:"YYYY-MM-DD" field with cmp

You beat me to your solution.

The why is context. Specifically, the original is in scalar context, which will return the size of the set of matched values (1)true or false. So your two values are both 1, and now (iirc) being a stable sort, returns the dates in the original order. The update takes the return value in list context, causing the results of the matches to be assigned to the provided variables.

Update: test my understanding of the return value from a pattern match, and correct the statement.

--MidLifeXis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found