Guay Jean-SÃbastien 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?
> 
> There is no problem syntactically. But there is a problem with the
> precdence. If you ever have another operation on either the left or right
> side of the || operator, the || operator will bind tighter than the other
> operation. So for example, if you do:
>

sure. i just don't want beginners to think: 'open(H,"F") || die' is wrong.

> 
> my $errors = 0;
> open (CRITICALSERVERS, "$crout") || $errors += 2;
> 
> that will translate to:
> 
> my $errors = 0;
> ( open (CRITICALSERVERS, "$crout") || $errors ) += 2;
> 

both of your examples above have syntax error so it's not *that* good of an 
example, perhaps you mean:

[panda]# perl -e 'open A,f or die'
Died at -e line 1.
[panda]#

instead of:

[panda]# perl -e 'open A,f || die'
[panda]#

> 
> Hope this explains this suggestion that might seem, at first, to come out
> of the blue!
>

it does. my main concern is not to confuse beginners who might think a 
certain construct should never be used. in this example, you sound like 
'or' should always be used instead of '||' when checking whether an open 
success or not.

david
-- 
s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$
\x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65
\x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72
\x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32
\x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74
\x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$;

-- 
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