in reply to Re^4: flip flop operator and if statement
in thread flip flop operator and if statement
Yes, if $p were being assigned the return value of the flip-flop operator, as in the OP, then it would indeed be incremented by one on each iteration in which the flip-flop operator evaluates to true. But by using parentheses in:
if(($p=3)..5)
you ensure that 3 is assigned to $p before the flip-flop operator is evaluated. Then the value of $p (now 3) is used in the evaluation of the flip-flop operator; and since 3 is “true” in Perl, the operator returns a sequence number (which is also true). That sequence number is not assigned to any variable, it’s just used to determine the outcome of the if statement.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: flip flop operator and if statement
by iThunder (Beadle) on Sep 26, 2014 at 23:05 UTC |