use strict; use warnings; my ($line, $length, $in, $out, $inh, $outh); $line = 'This is the temp line.'; $in = 'in.dat'; $out = 'out.dat'; $length = length($line) + 1; open ($inh, $in); open ($outh, ">$out"); while (<$inh>) { last if $length == length($_) && index($_, $line) != -1; } while (<$inh>) { print $outh $_; } close($outh); close($inh);