# read all the lines in the file into an array @all_lines = (); # grab only the lines you want @stripped_lines = splice(@all_lines, 3, scalar(@all_lines)-5); # output to the new file print OUTFILE @stripped_lines;