david wrote:

> Guay Jean-SĂ©bastien wrote:
> >
> >> open (CRITICALSERVERS, "$crout") || die "can't open file \n: $!";
> >
> > As I said, you should replace || by or in the above line. See the
> > precedence rules in "perldoc perlop" for details.
> >
>
> why do you think so? is there any problem in the above line?

Good point.  The explcit parentheses do indeed avoid the precedence problems
that would come with:

open CRITICALSERVERS, "$crout" || die "can't open file \n: $!";

Where the open function would take the second line as an alternative argument.

For instance, I have no file named 'crout' in my filesystem, yet:
Greetings! E:\d_drive\perlStuff>perl -w
open CRITICALSERVERS, 'crout' || die "can't open file \n: $!";
close CRITICALSERVERS;
^Z

does not produce an error message, because the die clause gets taken as an
alternative.  A stronger argument has to do with mindset.  The || operator is an
expression evaluation operator, appropriate to mathematical or paramathematical
expressions.  The context really calls for a flow-control operator, or.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to