while (<>) { if ( / ^ OVERVIEW \s $/x .. / ^ AFFECTED\ PRODUCTS \s $/x ) { print $_ unless /( ^ OVERVIEW \s $)|( ^ AFFECTED\ PRODUCTS \s $)/x; } }