Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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

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?
Corion had a meeting with some startup today. They have a very interesting DB proxy product, but their tech stack is really, really weird. They use the Pg wire protocol but not the Pg libraries to handle it. They support Pg SQL syntax, but don't use ...
[Corion]: ... the Pg parser (or so they claim).
[Corion]: Also, they rolled their own user management instead of supporting LDAP for user/role management, but that just shows that they're new in the enterprise market :)
Corion also just now realizes they didn't leave business cards.
[erix]: can you drop a name? :)
[karlgoethebier]: Corion: "...didn't leave business cards" Those guys came from Muršnia?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2018-04-19 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?