use strict; use warnings; local $/ = "\n\n"; while () { if (/\b(third|four)\b/si) { chomp; print "line is: $_\n"; } } __DATA__ This is line one. Line Two is this. Third line starts here. This is line four. This is line five going fourth. This is line six. This is the seventh line. This is line eight.