I am sorry David, it just seems like I am having trouble communicating clearly. We are apparently in a disagreement, but your points are not at all what I wanted to explain... I'll try again.
> you should test it yourself. i am not sure how good you are > with Perl and i > don't want to sound like i-know-Perl-more-than-you guy but > your example > won't even compile. 'perl -e' is exactly the same as if you > put it in a > script. why do you think there is a different? As you said, don't go there. I still consider myself a beginner, but I think you presume too much, as you might find out in what follows. I agree, they are not different in a strict sense, but if you have a long script, and try to run one line from that script in 'perl -e', it will obviously not work. Just consider this: In my first response to the OP, I took a few lines from his script and changed them, just to demonstrate a point. I never intended those few lines to be usable alone. I would have thought that obvious from the context. I'll just need to be clearer next time, sorry about that. > unfortunately, other than coding style, the following is > EXACTLY the same: > > [panda]# perl -e 'open(A,"F") || die' > [panda]# perl -e 'open A,"F" or die' True, but these are not. [panda]# perl -e 'open(A,"F") || $_ += 2' [panda]# perl -e 'open A,"F" or $_ += 2' which when deparsed, respectively give: open(A, 'F') || $_ += 2; $_ += 2 unless open A, 'F'; One gives a syntax error ( Can't modify logical or (||) in addition (+) at -e line 1, near "2;" ), the other works. So if you get used to using 'or' to check error status, no matter what you use on the left or right side of the 'or', it will work. That is what I meant. Getting used to some good practices early on is useful to prevent getting bitten by obscure bugs (yes, I refer to precedence as obscure, because not everyone knows their precedence table by heart, and it may take a little time to figure out that precedence is the problem). Of course, in all these cases, using parentheses to fix precedence is an alternative. But using or also makes the code read more like English, which (in my humble opinion) makes it easier to understand, and self-documenting. But that's very subjective... > you also failed to tell the OP > that they are the same and now the OP will never use '||' > again and he will > go around and spread that word that 'open(...) || die' is > wrong which is not! I don't remember ever saying it's wrong, or to never use '||'. Everything I said was personal preference, but I still think it's a good practice. If what I said was interpreted otherwise, I am sorry. Natural language is so ambiguous! :-) It's obviously all about context. In the context of checking error status, I believe it's better to use 'or', simply because of the precedence issue I noted above. But both work, obviously. And if you never use anything other than a simple die in the right-hand side of the '||', you'll never have a problem. But I prefer using 'or' even in those cases, simply because in 2 years, if I haven't done Perl for a few months, and I want to modify a program to use more complex error-handling, I might not remember to wrap it in parentheses. I hope I made my points clear. I am sorry if my first posts mislead anyone, or if the explanations left to be desired. I hope this message sets all of that straight.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>