Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Failed to create a file

by MidLifeXis (Monsignor)
on May 06, 2011 at 13:09 UTC ( #903377=note: print w/ replies, xml ) Need Help??


in reply to Failed to create a file

Slightly off topic, but related to coding style of sorts.

open(CFG, "C:\\TEMP\\cfg") || die "Failed to create cfg";

You have included the parens in your call to open, which allows the ... || die ... to work as expected. If you leave off the parens - open CFG, "C:\\TEMP\\cfg" || die "Failed to create cfg";, this will give you the wrong results. Having stubbed my toe on this many times, I have made it my habit to use action or die instead of action || die.

--MidLifeXis


Comment on Re: Failed to create a file
Select or Download Code
Replies are listed 'Best First'.
Re^2: Failed to create a file
by thezip (Vicar) on May 06, 2011 at 20:50 UTC

    An even alternativer solution to this is to use pjf's great autodie module, which avoids the issue altogether...


    What can be asserted without proof can be dismissed without proof. - Christopher Hitchens
Re^2: Failed to create a file
by tchrist (Pilgrim) on May 06, 2011 at 13:29 UTC
    Having stubbed my toe on this many times, I have made it my habit to use action or die instead of action || die.
    An alternative reaction is to always use parens on function calls: some_function(ARGS) || die. The advantage of this strategy is that it improves readability, plus now you donít have to memorize a bunch of confusing and conflicting precedence rules.
      I'm curious, which precedence rules are "conflicting"?

      Also I find the rule "logical operators that are spelled out as words have loose precedence" not too hard to remember.

        That doesnít tell you enough. Itís lower than a comma operator, which makes it unusable in data declarations. I simply gave up on it, and went back to using parens the way God and Dennis intended. Now I never make mistakes. Must safer, and easier to read, too.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2015-07-07 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls