my $op = shift;
my $type = $op->name;
if ($type eq "const") {
- if ($op->private & OPpCONST_ARYBASE) {
- return '$[';
- }
- return uninterp(escape_str(unback(const($self->const_sv($op)))));
+ return '$[' if $op->private & OPpCONST_ARYBASE;
+ return uninterp(escape_str(unback($self->const_sv($op)->as_string)));
} elsif ($type eq "concat") {
my $first = $self->dq($op->first);
my $last = $self->dq($op->last);
# Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]"
- if ($last =~ /^[{\[\w]/) {
- $first =~ s/([%\$@])([A-Za-z_]\w*)$/${1}{$2}/;
+ if ($last =~ /^[A-Z\\\^\[\]_?]/) {
+ $first =~ s/([\$@])\^$/${1}{^}/; # "${^}W" etc
+ }
+ elsif ($last =~ /^[{\[\w]/) {
+ $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/;
}
return $first . $last;
} elsif ($type eq "uc") {
my $op = shift;
my $type = $op->name;
if ($type eq "const") {
- return re_uninterp(escape_str(re_unback($self->const_sv($op)->PV)));
+ return '$[' if $op->private & OPpCONST_ARYBASE;
+ return re_uninterp(escape_str(re_unback($self->const_sv($op)->as_string)));
} elsif ($type eq "concat") {
my $first = $self->re_dq($op->first);
my $last = $self->re_dq($op->last);
# Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]"
- if ($last =~ /^[{\[\w]/) {
- $first =~ s/([%\$@])([A-Za-z_]\w*)$/${1}{$2}/;
+ if ($last =~ /^[A-Z\\\^\[\]_?]/) {
+ $first =~ s/([\$@])\^$/${1}{^}/;
+ }
+ elsif ($last =~ /^[{\[\w]/) {
+ $first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/;
}
return $first . $last;
} elsif ($type eq "uc") {