in reply to qr delimiter question

One point of alternate delimiters is to choose something you aren't trying to match as well. In your case, escaping the parens inside the regex is escaping their delimiting meaning, not their regex meaning. In other words, your embedded parens become simple capturing parens, not literal parens. Choose a different delimiter such as qr< ...>.