local $np; # I added this declaration myself $np = qr{ \{ (?: (?> [^{}]+ ) | (??{ $np }) )* \} }x;