Change 11109 by jhi@alpha on 2001/07/02 22:25:03

        Subject: [PATCH B::Deparse] hash key auto-quoting
        From: Robin Houston <[EMAIL PROTECTED]>
        Date: Mon, 2 Jul 2001 23:00:48 +0100
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/ext/B/B/Deparse.pm#89 edit

Differences ...

==== //depot/perl/ext/B/B/Deparse.pm#89 (text) ====
Index: perl/ext/B/B/Deparse.pm
--- perl/ext/B/B/Deparse.pm.~1~ Mon Jul  2 16:30:05 2001
+++ perl/ext/B/B/Deparse.pm     Mon Jul  2 16:30:05 2001
@@ -2669,6 +2669,16 @@
     #
     $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;
 }
 
End of Patch.

Reply via email to