in reply to Count capturing parentheses in a compiled regexp
In the spirit of "match the regex to get the number of parens in it", here's another way:
sub nparens { "" =~ /|$_[0]/ and $#+ }
In Section
Cool Uses for Perl