in reply to Re^2: Elegant examples to parse parenthesised strings (Parse::Balanced)
in thread Elegant examples to parse parenthesised strings

Add an "escape" token for those function calls:
@tokens = ( "(", qr/(?:[ab]func\([^)]*\))/, \@tokens, ")" );

Parsing contents in-between the function call parentheses is left as an exercise.

By the way, your second $str is unbalanced.