in reply to Works on one machine, fails on another

system() should return zero (false) on success, so use an 'and', not an 'or' operator. I don't have the precedence of operators memorized, but I'd also change the '||' to 'and' and not '&&'.

Update:After checking the precedence, it's not really necessary to use 'and' instead of '&&' here, but to me it makes the intention more clear.

Ups! duh. missed the '== 0'. More coffee for me please.

  • Comment on Re: Works on one machine, fails on another

Replies are listed 'Best First'.
Re: Re: Works on one machine, fails on another
by arturo (Vicar) on Feb 01, 2001 at 23:02 UTC

    ups! Yes, system returns 0 on success, so with the explict system('foo') ==0 || die "bar"; in this situation, that's just what's wanted. If the LHS of the || evaluates as true, Perl won't bother with the RHS.

    The use of &&/and you point to is equivalent to an if : If the LHS of an && is true, Perl goes on to evaluate the RHS, but doesn't bother if the LHS is false. So his code is correct on that aspect.

    I don't know enough Perl history to answer the original question, though =(

    Just for the record, the 'english' and and or are 'super-low precedence' versions of && and ||

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor