If you only need the final state. This code returns 'yes' only if there is an 'A' in the string and there is no 'B' after it.
in reply to Change variable multiple times within a single string?
Update: The original description is not quite accurate. It should read "This code returns 'yes' only if there is at least one 'A' in the string and there is no 'B' after the final 'A'."
my $yes_or_no= ($string =~ m/A[^B]*$/) ? 'yes' : 'no';