in reply to Parsing balanced parentheses

Three entries from perlfaq seem to be relevant:

Replies are listed 'Best First'.
Re^2: Parsing balanced parentheses
by rodion (Chaplain) on Jul 23, 2006 at 17:10 UTC
    The faqs are good, but I think the "How do I find matching/nesting anything?" in perlfaq4 should have something about handling the case when the delimiter may be present in a quoted string inside a matching set of delimiters. perlfaq4 mentions Text::Balanced, which talks about this case in the docs, but there's a good chance you will go use another module before you read about it, since it's 8 pages in.

    The case is a nasty little gotcha for applications like the OPs because it ususally doesn't show up on testing; the bug often waits in production code until you've forgotten what you wrote and how it works, then it blows up with a confusing error message.