This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #74740] Deparse -(f()) correctly
[perl5.git] / dist / B-Deparse / Deparse.pm
index 821cce1..10ab498 100644 (file)
@@ -1629,7 +1629,13 @@ sub pfixop {
     my($op, $cx, $name, $prec, $flags) = (@_, 0);
     my $kid = $op->first;
     $kid = $self->deparse($kid, $prec);
-    return $self->maybe_parens(($flags & POSTFIX) ? "$kid$name" : "$name$kid",
+    return $self->maybe_parens(($flags & POSTFIX)
+                                ? "$kid$name"
+                                  # avoid confusion with filetests
+                                : $name eq '-'
+                                  && $kid =~ /^[a-zA-Z](?!\w)/
+                                       ? "$name($kid)"
+                                       : "$name$kid",
                               $cx, $prec);
 }