in reply to Date manipulation

This is a solution regexp based. You should complete the %months hash to include all the other months.

use strict; use warnings; my @dates = <DATA>; my %months = ('Jan' => 1, 'Feb' => 2, 'Dec' => 12, ); foreach my $str_date (@dates) { $str_date =~ /^\w*\s*\w*\s*(\w*)\s*(\d*).*(\d{4})$/; my($month, $day, $year) = ($1, $2, $3); my $date = sprintf("%4d%02d%02d", $year, $months{$month}, $day); if($date gt "20080228") { print $str_date; } } __DATA__ usage1 Thu Feb 28 17:30:47 2008 usage2 Fri Feb 29 03:55:22 2008 usage3 Fri Feb 29 04:00:46 2008 usage4 Fri Feb 29 04:10:48 2008

That outputs

usage2 Fri Feb 29 03:55:22 2008 usage3 Fri Feb 29 04:00:46 2008 usage4 Fri Feb 29 04:10:48 2008

Replies are listed 'Best First'.
Re^2: Date manipulation
by shoness (Friar) on Jul 11, 2008 at 19:11 UTC
    If you've got it, you could use the groovy "named capture" feature of Perl 5.10 to change that regex to:
    $str_date =~ /^\w*\s*\w*\s*(?<month>\w*)\s*(?<day>\d*).*(?<year>\d +{4})$/;
    and then the usage to:
    my $date = sprintf("%4d%02d%02d", $+{year}, $months{$+{month}}, $+ +{day});

      Thank you for the suggestion.