use strict; my $count = 0; open (IN, "input.txt"); while () { if (/START/) { $count = 1; } elsif (/END/) { $count = 0; } elsif ($count) { print; } } close IN;