Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 ( #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

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

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? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2022-01-24 20:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?