in reply to grep for last 45 days

Um, about your sample data... I hope that isn't really what you have to cope with, because Dec. 5 2004 was a Sunday, not a Saturday. (And I hope you'll have at least some actual data that falls within the last 45 days, else what would be the point of a script that applies that threshold?)

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