$timestandard = time() - 604800; # time() will give us the number of seconds since the epoc # time() less 604800 seconds will give us the number of seconds since the epoc 7 days ago @data=&magic_fucntion_that_opens_the_file_and_gets_the_data(); foreach $d (@data) { push(@save, $d) if $d>$timestandard; } #so now all of the entries that are valid (ie. younger than one week old) are in the array @save #now we print them to the file open(SEZME, ">my_data_file.txt"); $,="\n"; print SEZME @save; close SEZME; undef($,); #the rest of the script.............