#grap the string from the file local $/=undef; open FILE, "messages.txt" or die "Couldn't open file: MESSAGES $!"; $string = ; close FILE; $string =~ tr/\n//d; #remove the last twenty lines: split it into an array by : @a = split(/:/,$string); splice (@a,0,-20); $stringb = join(':',@a); #fix up da file, so it dont have no more than 20 lines, foo! open MS, "> messages.txt"; print MS "$stringb"; close MS;