More precisely, at that point you have a bunch of numbers, but possibly not as many as expected if some of the components weren't numeric (or all of them, as when there are files present that aren't the expected logs). Which means some or all of those variables will be undefined instead of numbers. The // replaces those with the following value (0), so they do something sensible when sorted instead of producing warnings.
On Sat, Jun 9, 2018 at 11:40 AM Xin Cheng <xinchen...@gmail.com> wrote: > This is very interesting. But I wonder how it works. I can understand the > first line > > my ($month, $day, $year, $hour, $minute, $second) = .comb(/\d+/); > > Which extract the variables from $_. What is the second line doing, it is > very concise. > > ($year // 0, $month // 0, $day // 0, $hour // 0, $minute // 0, > $second // 0, $_); > > Could somebody explain in some more words.? What does // do? Why it sorts > the array? > > Regards > > Xin > > On Jun 9, 2018, at 12:51 AM, Timo Paulssen <t...@wakelift.de> wrote: > > That's unnecessarily long and complicated, here's how you can do it much > easier: > > @x.sort: { > my ($month, $day, $year, $hour, $minute, $second) = .comb(/\d+/); > ($year // 0, $month // 0, $day // 0, $hour // 0, $minute // 0, > $second // 0, $_); > } > > Trying it on some input data: > > cimtrak.log.06-08-2018_16:07:39.zip > cimtrak.log.06-08-2018_17:07:39.zip > cimtrak.log.07-08-2018_06:07:39.zip > cimtrak.log.07-08-2018_16:07:39.zip > cimtrak.log.12-08-2016_06:07:39.zip > cookies > asbestos > fire engine > perl6 > butterflies > > results in: > > asbestos > butterflies > cookies > fire engine > perl6 > cimtrak.log.12-08-2016_06:07:39.zip > cimtrak.log.06-08-2018_16:07:39.zip > cimtrak.log.06-08-2018_17:07:39.zip > cimtrak.log.07-08-2018_06:07:39.zip > cimtrak.log.07-08-2018_16:07:39.zip > > This is the schwartzian transform that was mentioned in another mail. > why it wasn't actually shown, i have no clue :) > > Hope that helps > - Timo > > > -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net