in reply to match function

What is your question?

I think the error message is quite clear:

Unmatched [ in regex; marked by <-- HERE in m/([ <-- HERE B|b)

There is an unmatched opening square bracket in your regular expression.

Your regular expression is

/([B|b)/

Maybe you wanted to write [Bb], or maybe ([B|b])? But that's not what you wrote.

Also, the following code will most certainly not do what you think it does:

if ($_ = /([A|a])/) {

Most likely, you want to use the regex binding operator =~ and not the assignment operator =.