From: Albert Dvornik Date: Tue, 11 May 1999 13:32:04 +0000 (-0400) Subject: deparse \&func() as \(&func()) for clarity X-Git-Tag: perl-5.6.0~1411 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/c8c62db702b7e7b28e0c00febb0781eff4341baf?hp=45c0de28763808112fd2f46ea311b6bb0c6050b3;ds=inline deparse \&func() as \(&func()) for clarity Message-ID: Subject: [PATCH 5.005_56] Deparse and \&func() (was Re: File::Find...) p4raw-id: //depot/perl@3400 --- diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm index 3abb39a..5543a7b 100644 --- a/ext/B/B/Deparse.pm +++ b/ext/B/B/Deparse.pm @@ -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); }