diff options
author | Robin Houston <robin@cpan.org> | 2001-05-08 02:14:55 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-05-07 23:22:48 +0000 |
commit | cdf8218f4ad909c2193b756d53edeceefec447d4 (patch) | |
tree | 58d44a47114e8144347dc0ddf5f1d3214f4b4347 /ext/B | |
parent | a403baf6db062a9762514a55376b87d7258108a5 (diff) | |
download | perl-cdf8218f4ad909c2193b756d53edeceefec447d4.tar.gz |
Give (?{...}) a taste of its own medicine
Message-ID: <20010508011455.A32162@penderel>
p4raw-id: //depot/perl@10027
Diffstat (limited to 'ext/B')
-rw-r--r-- | ext/B/B/Deparse.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 959bb37eaf..ae4043bfa8 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; } |