return "tr" . double_delim($from, $to) . $flags;
}
+sub re_dq_disambiguate {
+ my ($first, $last) = @_;
+ # Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]"
+ ($last =~ /^[A-Z\\\^\[\]_?]/ &&
+ $first =~ s/([\$@])\^$/${1}{^}/) # "${^}W" etc
+ || ($last =~ /^[{\[\w_]/ &&
+ $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/);
+ return $first . $last;
+}
+
# Like dq(), but different
sub re_dq {
my $self = shift;
} elsif ($type eq "concat") {
my $first = $self->re_dq($op->first, $extended);
my $last = $self->re_dq($op->last, $extended);
-
- # Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]"
- ($last =~ /^[A-Z\\\^\[\]_?]/ &&
- $first =~ s/([\$@])\^$/${1}{^}/) # "${^}W" etc
- || ($last =~ /^[{\[\w_]/ &&
- $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/);
-
- return $first . $last;
+ return re_dq_disambiguate($first, $last);
} elsif ($type eq "uc") {
return '\U' . $self->re_dq($op->first->sibling, $extended) . '\E';
} elsif ($type eq "lc") {
my $str = '';
$kid = $kid->first->sibling;
while (!null($kid)) {
- $str .= $self->re_dq($kid, $extended);
+ my $first = $str;
+ my $last = $self->re_dq($kid, $extended);
+ $str = re_dq_disambiguate($first, $last);
$kid = $kid->sibling;
}
return $str, 1;
require feature;
feature->import(':5.10');
}
-use Test::More tests => 60;
+use Test::More tests => 61;
use B::Deparse;
my $deparse = B::Deparse->new();
elsif ($a and $b) { x(); }
elsif ($a or $b) { x(); }
else { x(); }
+####
+# 54 interpolation in regexps
+my($y, $t);
+/x${y}z$t/;