Friday, March 25, 2011

Sorting Human-Readable Dates in Perl with Date::Parse

#!/usr/bin/perl 
use warnings;
use strict;

use Date::Parse;

# Read from the DATA block, sort chronologically, and print
print for sort { str2time($a) <=> str2time($b) } <DATA>;

__DATA__
March 9, 2010
April 2, 2008
January 23, 2009
April 1, 2008

No comments: