if ( /D (.{3}) [A-Z]{3,15} (\d{6,8}) [^D]{2}/x and 2 <= ( $1 =~ tr/F//) # first capture contains at least two F's and 3 <= ( $2 =~ tr/1//) # second capture contains at least three 1's ) { # get here when all conditions are met }