in reply to Re: if and
in thread if and

While this code example does still work, it represents, to a certain extent, a failure in development logic.

The case scenario given is that two conditions must be true for a true result to the expression - The order of developer logic should follow testing each condition individually and then applying the AND logic to the condition results. The application of conditions within parentheses as given by BeernuT follows this order.

With the code given, this only works because of the precedence of operands as described in perlop.

 

Update

By failure of development logic, I refer not to the deparsing of code, because as highlighted by blakem below (++blakem), the result is identical, but rather the logic driving the writing of the code. In this instance, Anonymous Monk voiced confusion in order and syntax, presumably the result of trying to merge everything together without respect to the individual order of elements within the logic process.

This node was intended to direct discussion towards cause moreso than effect.

 

perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

Replies are listed 'Best First'.
Re3: if and
by blakem (Monsignor) on Feb 20, 2002 at 08:17 UTC
    Assuming you're discussing (($x1 eq $y1) and ($x2 eq $y2)) vs. ($x1 eq $y1 && $x2 eq $y2)

    Since, they deparse to the same thing, how can one be a "failure"? Are you claiming that they do different things, or that one is harder to understand and maintain?

    % perl -MO=Deparse -e'if($x1 eq $y1 && $x2 eq $y2){}' if ($x1 eq $y1 and $x2 eq $y2) { (); } % perl -MO=Deparse -e'if(($x1 eq $y1) and ($x2 eq $y2)){}' if ($x1 eq $y1 and $x2 eq $y2) { (); }

    -Blake

      I was merely commenting on the fact that Anonymous Monk stated that the code didn't work, I was just showing that the code did work. Whether or not there's a flaw in the developer logic is a seperate subject entirely.

      But rob_au++ and blakem++ regardless.

      Update: sorry blakem in a pre-caffeine haze I replied to your comment, this was meant to be a reply to rob_au's comment. Please disregard.