Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Re: Re: system & shell metacharacters

by snax (Hermit)
on Jul 23, 2003 at 12:39 UTC ( [id://277240]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Re: Re: system & shell metacharacters
in thread system & shell metacharacters

Really? Ya learn something new every day :) I have a great number of scripts to modify, it would seem....
  • Comment on Re: Re: Re: Re: system & shell metacharacters

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: system & shell metacharacters
by vek (Prior) on Jul 23, 2003 at 14:14 UTC
    Using || die is fine as long as parens are used.
    open(FOO, $file) || die "Couldn't open $file - $!\n";

    When no parens are present, you should use or die instead.

    Personally, I always use parens everywhere so my code is littered with || dies.

    -- vek --
      I'm just surprised that I've never seen a problem using it exactly as I've written it above, which I do with great regularity. The docs say that the calling signatures are
      open FILEHANDLE, EXPR
      and
      open FILEHANDLE
      My syntax falls into the first case, but what constitutes an "EXPR"? I've got a string, the || operator, then the die -- does that qualify as an EXPR? I'll have to poke around the docs some more.....

      Oh. Playing around with the right and wrong way shows me that my "|| die" syntax fails without die-ing.

        I've got a string, the || operator, then the die -- does that qualify as an EXPR?
        Yes, it does (as you seem to have discovered): since || is higher precedence than the comma, it's parsed roughly as open ( FILEHANDLE, ("filename" || die( ...) ) ); Since your string is always true, the die is never reached.



        If God had meant us to fly, he would *never* have given us the railroads.
            --Michael Flanders

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277240]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.