if ( /ABC(...).E/ and 2 <= ( $1 =~ tr/D// )) { # get here when the captured region contains 2 or 3 D's }