From: Robin Houston Date: Tue, 8 May 2001 01:14:55 +0000 (+0100) Subject: Give (?{...}) a taste of its own medicine X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cdf8218f4ad909c2193b756d53edeceefec447d4;p=p5sagit%2Fp5-mst-13.2.git Give (?{...}) a taste of its own medicine Message-ID: <20010508011455.A32162@penderel> p4raw-id: //depot/perl@10027 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 959bb37..ae4043b 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -2930,7 +2930,36 @@ sub uninterp { # the same, but treat $|, $), $( and $ at the end of the string differently sub re_uninterp { my($str) = @_; - $str =~ s/(^|\G|[^\\])((?:\\\\)*)([\$\@](?!\||\)|\(|$)|\\[uUlLQE])/$1$2\\$3/g; + + use re "eval"; + # Matches any string which is balanced with respect to {braces} + my $bal = qr( + (?: + [^\\{}] + | \\\\ + | \\[{}] + | \{(??{$bal})\} + )* + )x; + + $str =~ s/ + ( ^|\G # $1 + | [^\\] + ) + + ( # $2 + (?:\\\\)* + ) + + ( # $3 + (\(\?\??\{$bal\}\)) # $4 + | [\$\@] + (?!\||\)|\(|$) + | \\[uUlLQE] + ) + + /length($4) ? "$1$2$4" : "$1$2\\$3"/xeg; + return $str; }