This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deparse: readpipe with complex expression
authorFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2011 21:03:41 +0000 (14:03 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2011 21:44:06 +0000 (14:44 -0700)
readpipe was always being deparse as `...` or qx.

This commit changes it to use the already-existing pure_string routine
to determine whether it can fit in `` first.

dist/B-Deparse/Deparse.pm
dist/B-Deparse/t/deparse.t

index be2406f..e780ab8 100644 (file)
@@ -3834,7 +3834,10 @@ sub pp_backtick {
     # skip pushmark if it exists (readpipe() vs ``)
     my $child = $op->first->sibling->isa('B::NULL')
        ? $op->first : $op->first->sibling;
     # skip pushmark if it exists (readpipe() vs ``)
     my $child = $op->first->sibling->isa('B::NULL')
        ? $op->first : $op->first->sibling;
-    return single_delim("qx", '`', $self->dq($child));
+    if ($self->pure_string($child)) {
+       return single_delim("qx", '`', $self->dq($child, 1));
+    }
+    unop($self, @_, "readpipe");
 }
 
 sub dquote {
 }
 
 sub dquote {
index dcb18ba..802c31f 100644 (file)
@@ -702,3 +702,6 @@ glob('a,');
 each $@;
 keys $~;
 values $!;
 each $@;
 keys $~;
 values $!;
+####
+# readpipe with complex expression
+readpipe $a + $b;