in reply to Re: Max date from set of dates
in thread Max date from set of dates
The fastest way to do the max date function in the YYYY-MM-DD case is to use List::Util. That is because List::Util and List::Util::More are implemented as XS (C code).
This is actually such a big advantage that sometimes it is worth it performance wise to fix "malformed" dates to have the leading zeroes before doing min,max or range searches. The Perl string compare goes quickly.#!/usr/bin/perl -w use strict; # here only maxstr is needed, just showing them all... use List::Util qw(first max maxstr min minstr reduce shuffle sum); my @dates = ( '2011-03-12', '2011-04-09', '2010-12-31', '2010-12-30'); print maxstr(@dates),"\n"; #2011-04-09
Update: List::Util is a core module, meaning that it is already on your system without having to install any extra modules.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Max date from set of dates
by perlVIP (Initiate) on Nov 01, 2013 at 15:17 UTC |