in reply to Parsing file to pull out sections of text

One way is to use Range Operators:
use strict; use warnings; while (<DATA>) { print if (/d1/ .. /d4/); } __DATA__ a b c d d1 d2 d3 d4 a b d1 d2 d4 a f g

prints:

d1 d2 d3 d4 d1 d2 d4