use strict; use warnings; my ($trigger, $fh_in, $fh_out); my $split_text = 'This is the temp line.'; my $in = 'input_file.dat'; my $out = 'output_file.dat'; open ($fh_in, $in) or die "ERROR: opening file $in: $@\n"; open ($fh_out, ">$out") or die "ERROR: opening file $out: $@\n"; undef $trigger; while (<$fh_in>) { unless($trigger || /$split_text/) { next; } # END unless($trigger || /$split_text/) if(/$split_text/) { $trigger=1; next; # Else delete or comment out this line if you want the split_line printed. } # END if(/$split_text/) print $fh_out $_; } # END while (<$fh_in>) close($fh_in); close($fh_out);