From: Robin Houston Date: Mon, 2 Jul 2001 23:00:48 +0000 (+0100) Subject: hash key auto-quoting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=098251bcb15bdcfcdaad5380bc3510d276692cd1;p=p5sagit%2Fp5-mst-13.2.git hash key auto-quoting Message-Id: p4raw-id: //depot/perl@11109 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index e9426ce..2e0921f 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; }