deparse \&func() as \(&func()) for clarity
authorAlbert Dvornik <bert@genscan.com>
Tue, 11 May 1999 13:32:04 +0000 (09:32 -0400)
committerGurusamy Sarathy <gsar@cpan.org>
Wed, 12 May 1999 10:40:11 +0000 (10:40 +0000)
Message-ID: <tqk8ufwm0b.fsf@puma.genscan.com>
Subject: [PATCH 5.005_56] Deparse and \&func() (was Re: File::Find...)

p4raw-id: //depot/perl@3400

ext/B/B/Deparse.pm

index 3abb39a..5543a7b 100644 (file)
@@ -962,13 +962,22 @@ sub pp_refgen {
                 $kid->sibling->ppaddr eq "pp_anoncode") {
            return "sub " .
                $self->deparse_sub($self->padval($kid->sibling->targ));
-       } elsif ($kid->ppaddr eq "pp_pushmark"
-                and $kid->sibling->ppaddr =~ /^pp_(pad|rv2)[ah]v$/
-                and not $kid->sibling->flags & OPf_REF) {
-           # The @a in \(@a) isn't in ref context, but only when the
-           # parens are there.
-           return "\\(" . $self->deparse($kid->sibling, 1) . ")";
-       }
+       } elsif ($kid->ppaddr eq "pp_pushmark") {
+            my $sib_ppaddr = $kid->sibling->ppaddr;
+            if ($sib_ppaddr =~ /^pp_(pad|rv2)[ah]v$/
+                and not $kid->sibling->flags & OPf_REF)
+            {
+                # The @a in \(@a) isn't in ref context, but only when the
+                # parens are there.
+                return "\\(" . $self->deparse($kid->sibling, 1) . ")";
+            } elsif ($kid->sibling->ppaddr eq 'pp_entersub') {
+                my $text = $self->deparse($kid->sibling, 1);
+                # Always show parens for \(&func()), but only with -p otherwise
+                $text = "($text)" if $self->{'parens'}
+                                 or $kid->sibling->private & OPpENTERSUB_AMPER;
+                return "\\$text";
+            }
+        }
     }
     $self->pfixop($op, $cx, "\\", 20);
 }