![]() |
|
Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Get most recent data based on a date from an array of hashes.by johngg (Canon) |
on Jan 19, 2022 at 00:30 UTC ( #11140599=note: print w/replies, xml ) | Need Help?? |
You can use Time::Piece (which is core) to get the epoch seconds from the date. The epoch key/value pair can then be added to the hash ref. for sort'ing numerically and then delete'ed from the hash ref. afterwards. You can then take the last element from the sorted items to get the latest date.
Produces
I hope this is helpful. Update: Expanded wording re. use of the temporary epoch key/value pair. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|