Supersearch didn't turn anything up and I can't figure out if Parse::RecDescent will do this:
What I want is a subroutine that matches a set of nested parens. That is, what I'd like is:
$str = "(a a (a a)(a a))(b b(b)b b)"
and have
my ($parens, $rest) = match($str) ;
and have $parens end up with "a a (a a)(a a)" and $rest be "(b b(b)b b)" I seem to recall doing something like this when I was an undergraduate and it involved something like counting parens [that is, count +1 for a ( and -1 for a ) and you've got the first balanced set when the count == 0. Is there a more elegant way to do it in Perl?