Convert the dates to a numerical, fixed-width, greatest significance first format. For instance, if you have Feb 12, 06, you could translate that to 060112, then compare numerically:
use strict;
use warnings;
my $date1 = dateconvert('Jan 11, 04');
my $date2 = dateconvert('Jan 30, 04');
my $date3 = dateconvert('Feb 10, 04');
print "$date1 <= $date2 <= $date3 ? ";
print $date1 <= $date2 && $date2 <= $date3 ? "Yes" : "No";
BEGIN {
my @mon = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
my %mon; $mon{$mon[$_]} = $_ for 0..$#mon;
sub dateconvert {
my $date = $_[0];
my ($mon, $day, $year) = $date =~ m/(\w+) (\d+), (\d+)/;
$mon = $mon{$mon};
return sprintf("%02d%02d%02d", $year, $mon, $day);
}
}
This is easily modified for different formats by changing a couple lines in the function.