in reply to grep for last 45 days
As for your problem, if you look at the docs for the first module suggested in the first reply, and just play with Date::Manip in the simplest possible experiment, I think you'd get what you want. For example (replacing your bad sample data with some relevant data):
#!/usr/bin/perl use strict; use Date::Manip; my $limit = DateCalc( 'now', '- 45 days' ); while (<DATA>) { my $datestr = (split / : /)[0]; # note spaces around ":" print if ( ParseDate( $datestr ) > $limit ); } __DATA__ Fri Dec 3 23:07:21 EST 2004 : Depth is : 234 Sat Dec 4 00:07:29 EST 2004 : Depth is : 123 Sat Feb 26 14:13:12 EST 2005 : Depth is : 4567
|
|---|