foreach $line (0..$#file) { # grab the date and dump into $date $date = $1 if $file[line] =~ m/^\[(.*?)\]/; # parse it to unix time $date = str2time($date); # method from Date::Parse # if its older than a month (30 days specifically) if($date < (time-2592000)) # 2592000 secs = 30 days { splice @file,$line,1; } }