$str = 'ABABAABBA'; $count = $str =~ tr/A//; # $a = 5; #### if ($count && !($count & 1)) { # Do something with this protein sequence }