Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by wind (Priest)
on Apr 30, 2011 at 02:29 UTC ( [id://902111]=note: print w/replies, xml ) Need Help??


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

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        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://902111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-28 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found