I am not aware of the built-in magic array that contains all the groups in brackets, but this does not stop you from doing the following:
{package Match::Parens;
sub TIEARRAY {bless []}
sub FETCH {no strict 'refs'; ${$_[1] + 1}}
sub FETCHSIZE {$#+}
tie @!, __PACKAGE__;
}
sub mySubst {join ', ' => map ucfirst, @_}
my $str = 'foobarbarbaz';
$str =~ s/(foo)(bar)+(baz)/mySubst(@!)/e;
say $str;
, Match::Parens @! . , , . 0, , , 1, vars $1, $2, $3.