Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Get most recent data based on a date from an array of hashes.by choroba (Cardinal) |
on Jan 18, 2022 at 17:46 UTC ( [id://11140572]=note: print w/replies, xml ) | Need Help?? |
Dates can be compared as strings if they follow the YYYY-MM-DD pattern (compulsory xkcd reference).
For longer lists, you might want to use the Schwartzian transform so Perl doesn't have to convert each date several times. Better yet, store the dates directly in the YYYY-MM-DD format and you can sort them the way you wanted.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|