Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Re: Re: open failure code

by jweed (Chaplain)
on Nov 27, 2003 at 02:50 UTC ( #310452=note: print w/replies, xml ) Need Help??

in reply to Re: Re: open failure code
in thread open failure code

Though this works, the ternary operator, like the grep and map operators, should not really be use in void context.
if (open(FH,"<".$log) { print "opened\n"; } else { print "unable to open $!\n"; }
is preferred.

Who is Kayser Söze?

Replies are listed 'Best First'.
Re: Re: Re: Re: open failure code
by davido (Cardinal) on Nov 27, 2003 at 05:47 UTC
    Of course the same could be done just with proper logical short circuit operators. Prefer the low-precedence ones for this sort of thing:

    open FH, "<", $log and print "Success\n" or print "Failure\n";

    That avoids trinaries and if/else's.


    "If I had my life to live over again, I'd be a plumber." -- Albert Einstein

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-04-13 23:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found