in reply to Parsing balanced parentheses

The big problem you can run into with parsing balanced elements comes when one of your delimiters shows up within the quotes. What happens if one of the "xxx" items contains "the enclosing '{}'", or even, "the closing '}'". If you can be sure this will never be in the data, then the task is reasonably simple, whether you write your parser or learn how to build a grammer for one of the parsing modules.

If there is any chance the data will contain your delimiter, you should go to Text::Balanced, and check the section with the example

$text = '<A HREF=">>>>">link</A>'; into ( '<A HREF=">>>>">', 'link</A>', "" )
That module is also worth bing familiar with because the tasks it handles come up a lot in contexts where you don't want to switch over to thinking about a recursive grammar.