Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: "or die" versus "|| die"

by brian_d_foy (Abbot)
on Jun 24, 2005 at 15:59 UTC ( #469746=note: print w/ replies, xml ) Need Help??


in reply to Re: "or die" versus "|| die"
in thread "or die" versus "|| die"

Which error? The numeric comparison operator has a higher precedence. If the record size that perl read is the expected record size, the LHS evaluates to one and the short circuit terminates.

The better rule of thumb is to use or when you want everything else to happen first.

If you know about problems in the perlfaq, however, you can send them to perlfaq-workers @ perl.org and we'll fix them up.

--
brian d foy <brian@stonehenge.com>


Comment on Re^2: "or die" versus "|| die"
Download Code
Re^3: "or die" versus "|| die"
by halley (Prior) on Jun 24, 2005 at 16:33 UTC
    In terms of your "rule of thumb," I like to say that || goes between expressions, and or goes between statements. It's kinda like how , goes between elements, but ; goes between statements. I'm not sure if my phrasing is any more clear to the uninitiated than talking in greek, though.

    --
    [ e d @ h a l l e y . c c ]

      That's not a good rule though because it doesn't actually provide useful guidance and it makes people think about the operators all wrong. It has nothing to do with expressions or statements. It's all about operators and in which order perl evaluates them. That's the information you need to pass on in your rule so that people can figure out what to do.

      --
      brian d foy <brian@stonehenge.com>
Re^3: "or die" versus "|| die"
by ysth (Canon) on Jun 24, 2005 at 19:11 UTC
    Gah, you are right, and I should know better.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-12-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (164 votes), past polls