Re: [ID 20010330.003] O=Deparse,-p does not preserve "operational semantics"
authorRobin Houston <robin@cpan.org>
Fri, 30 Mar 2001 20:07:22 +0000 (21:07 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 30 Mar 2001 23:33:44 +0000 (23:33 +0000)
Message-ID: <20010330200722.A2010@puffinry.freeserve.co.uk>

p4raw-id: //depot/perl@9482

ext/B/B/Deparse.pm

index 5629c17..32baa50 100644 (file)
@@ -573,7 +573,11 @@ sub maybe_local {
     my $self = shift;
     my($op, $cx, $text) = @_;
     if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{$$op}) {
-       return $self->maybe_parens_func("local", $text, $cx, 16);
+        if (want_scalar($op)) {
+           return "local $text";
+       } else {
+           return $self->maybe_parens_func("local", $text, $cx, 16);
+       }
     } else {
        return $text;
     }
@@ -601,7 +605,11 @@ sub maybe_my {
     my $self = shift;
     my($op, $cx, $text) = @_;
     if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{$$op}) {
-       return $self->maybe_parens_func("my", $text, $cx, 16);
+       if (want_scalar($op)) {
+           return "my $text";
+       } else {
+           return $self->maybe_parens_func("my", $text, $cx, 16);
+       }
     } else {
        return $text;
     }