in reply to Re: Efficient way to match and replace nested braces (etc.)
in thread Efficient way to match and replace nested braces (etc.)

Even better:
my $re = '{{(?:[^{}]+|'; $re .= $re x ($nested) . "\b" . ')*}}' x ($nested + 1);