my @lines = qw(foo BEGIN bar baz END qux); for (@lines) { if (/BEGIN/ .. /END/) { print "$_\n"; } } while () { if (3 .. 5) { print; } } __DATA__ Line one Line two The third and fourth what about the fifth? or the sixth?