This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #47361] Deparse do +{} and do({}) correctly
authorFather Chrysostomos <sprout@cpan.org>
Wed, 7 Dec 2011 20:41:56 +0000 (12:41 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 8 Dec 2011 14:18:08 +0000 (06:18 -0800)
These are both variants of do-file syntax.

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

index 8aecf88..8bf5756 100644 (file)
@@ -1762,7 +1762,11 @@ sub pp_gmtime { unop(@_, "gmtime") }
 sub pp_alarm { unop(@_, "alarm") }
 sub pp_sleep { maybe_targmy(@_, \&unop, "sleep") }
 
-sub pp_dofile { unop(@_, "do") }
+sub pp_dofile {
+    my $code = unop(@_, "do");
+    if ($code =~ s/^do \{/do({/) { $code .= ')' }
+    $code;
+}
 sub pp_entereval {
     unop(
       @_,
index a81c86e..492c691 100644 (file)
@@ -828,3 +828,10 @@ BEGIN { $^H{'a'} = 'b'; }
  print $_;
 }
 print $_;
+####
+# [perl #47361] do({}) and do +{} (variants of do-file)
+do({});
+do +{};
+>>>>
+do({});
+do({});