open FILE, 'myfile.txt' or die "Urgh: $!\n"; while () { if (/START TEXT/ .. /END TEXT/) { # Do something with the text in $_ # This will be one line from the file # after the line containing 'START TEXT' # but before the line containing 'END TEXT' } }