summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2001-07-03 00:00:48 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-02 22:25:03 +0000
commit098251bcb15bdcfcdaad5380bc3510d276692cd1 (patch)
tree7cf82d87243a19a346c56b725d46ae05494c3905 /ext
parentd35bf2f7dc52dfa2e6a832566c17bdb2cd355777 (diff)
downloadperl-098251bcb15bdcfcdaad5380bc3510d276692cd1.tar.gz
hash key auto-quoting
Message-Id: <E15HBmR-0006mc-00.2001-07-02-23-02-55@mail18.svr.pol.co.uk> p4raw-id: //depot/perl@11109
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B/Deparse.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index e9426ce278..2e0921f381 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -2669,6 +2669,16 @@ sub elem {
#
$idx =~ s/^\((.*)\)$/$1/ if $self->{'parens'};
+ # Hash-element braces will autoquote a bareword inside themselves.
+ # We need to make sure that C<$hash{warn()}> doesn't come out as
+ # C<$hash{warn}>, which has a quite different meaning. Currently
+ # B::Deparse will always quote strings, even if the string was a
+ # bareword in the original (i.e. the OPpCONST_BARE flag is ignored
+ # for constant strings.) So we can cheat slightly here - if we see
+ # a bareword, we know that it is supposed to be a function call.
+ #
+ $idx =~ s/^([A-Za-z_]\w*)$/$1()/;
+
return "\$" . $array . $left . $idx . $right;
}