in reply to Say it isn't so, -MO=Deparse!

I'm afraid -MO=Deparse is wrong.

$x = (4, 5, 6) is a scalar assignment, assigning 6 to $x, and returning $x in scalar context.

($x) = (4, 5, 6) is a list assignment, assigning 4 to $x, and returning 3 (elements on the right) in scalar context.

FWIW, this happens for me in 5.6.2, but not in any perl 5.8.0 or greater. Update: by "this", I mean the bug where Deparse drops the () around the $x, changing what should be a list assignment into a scalar assignment. The behaviours I cite above of list and scalar assignments are correct and documented.

Replies are listed 'Best First'.
Re^2: Say it isn't so, -MO=Deparse!
by tlm (Prior) on Apr 03, 2005 at 23:26 UTC

    FWIW, this happens for me in 5.6.2, but not in any perl 5.8.0 or greater.

    That was the problem! (My environment had gotten corrupted, so that "perl" was no longer pointing to my personal v5.8.4 but the system's outdated v5.6.1.)

    Thanks!

    the lowliest monk

Re^2: Say it isn't so, -MO=Deparse!
by moot (Chaplain) on Apr 04, 2005 at 04:13 UTC
    Well this can't be good.
    $ perl -le '$_ = ($x) = (4, 5, 6); print' 3 $ perl -le '($_ = ($x = (4, 5, 6))); print($_)' 6 $ perl -MO=Deparse,-p -le '$_ = ($x) = (4, 5, 6); print' BEGIN { $/ = "\n"; $\ = "\n"; } ($_ = (($x) = (4, 5, 6))); print($_); -e syntax OK $ perl -v This is perl, v5.8.3 built for i586-linux-thread-multi
    I would like to upgrade, but this is a managed system..
      I would like to upgrade, but this is a managed system
      No need, your perl doesn't have the bug. I'm guessing you misunderstood some part of what I said above, but can't guess which part.