sub nparens { "" =~ /|$_[0]/ and $#+ } [download]
In reply to Re: Count capturing parentheses in a compiled regexp by japhy in thread Count capturing parentheses in a compiled regexp by BooK