use Regexp::Common; my $str = < '{}'})/; __output__ { foo { bar {} } }