in reply to Get most recent data based on a date from an array of hashes.
Dates can be compared as strings if they follow the YYYY-MM-DD pattern (compulsory xkcd reference).
sub mdy2ymd { my ($mdy) = @_; $mdy =~ /(..)-(..)-(....)/ and return "$3-$1-$2"; } my @filtered = sort { mdy2ymd($a->{Date}) cmp mdy2ymd($b->{Date}) } @$data;
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