in reply to
Change variable multiple times within a single string?
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.
my $yes_or_no= ($string =~ m/A[^B]*$/) ? 'yes' : 'no';
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'."