use strict; use warnings; use Time::Local (); my $file_name = shift(@ARGV); open(LOG_FH, '<', $file_name) or die("...$/"); open(TMP_FH, '>', $file_name.'.tmp') or die("...$/"); # Might want to clear the hours, minutes and secs from $old. my $old = time - 90*24*60*60; while () { my ($y, $m, $d) = /...(...)...(...)...(...).../; my $date = Time::Local::timelocal(0, 0, 0, $d, $m-1, $y); last if $date > $old; } do { print TMP_FH $_; } while (); close(LOG_FH); close(TMP_FH); unlink($file_name); rename($file_name.'.tmp', $file_name);