in reply to Re: Get most recent data based on a date from an array of hashes.
in thread Get most recent data based on a date from an array of hashes.
I tried, but still getting all the data instead of the most recent:
sub mdy2ymd { my ($mdy) = @_; $mdy =~ s/^(\d{1,2})\D(\d{1,2})\D(\d{4}|\d{4}\s+).*/$1\-$2\-$3/; return "$3-$1-$2"; } my @filtered = sort { mdy2ymd($a->{Date}) cmp mdy2ymd($b->{Date}) } @$data; print Dumper @filtered;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Get most recent data based on a date from an array of hashes.
by Fletch (Bishop) on Jan 18, 2022 at 18:45 UTC | |
by Anonymous Monk on Jan 18, 2022 at 19:10 UTC | |
by Fletch (Bishop) on Jan 18, 2022 at 19:59 UTC | |
by Anonymous Monk on Jan 19, 2022 at 17:52 UTC | |
by Fletch (Bishop) on Jan 19, 2022 at 18:19 UTC |
In Section
Seekers of Perl Wisdom