http://qs321.pair.com?node_id=1130654


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