in reply to Re^2: Without trying; what do you think this would print? (/left/ side)
in thread Without trying; what do you think this would print?

You're right tye, it's a bug. The following should be equivalent:

$ perl -e '$a{0} = $a{0} || scalar keys %a; print $a{0}' 0 $ perl -e '$a{0} ||= scalar keys %a; print $a{0}' 1

Tested on 5.8, 5.10, and 5.12

  • Comment on Re^3: Without trying; what do you think this would print? (/left/ side)
  • Download Code

Replies are listed 'Best First'.
Re^4: Without trying; what do you think this would print? (notabug!)
by tye (Sage) on Apr 30, 2011 at 15:49 UTC

    No, it isn't. No, they need not be.

    - tye        

      Well, from my basic understanding of perlop - Assignment Operators those two should be equivalent. Maybe I'm wrong though.

      Fortunately, it's a contrived example anyway.

        Yes. They are both even equivalent to the point of either producing 0 or 1 depending on implementation details including optimizations.

        - tye