in reply to
Eternal question of parsing parentheses
recursive algorithm for nested data structures
has a couple of answers, and there's
Text::Balanced
Comment on
Re: Eternal question of parsing parentheses
In Section
Seekers of Perl Wisdom