in reply to undefined backreferences

Put the quantifier inside the parentheses instead of outside the parentheses:

$line =~ s/-=(A)([][]?)(B)([][]?)/<b>$1$2$3<\/b>$4/g;