in reply to AND OR
As in shell usage, this can be used to good effect, to perform (or skip) an action based on the outcome of previous action. (It can also be a trap for the unwary.)sub f0 { return 0 } sub f1 { return 1 } if (( my $x = f1() ) && ( my $y = f1() )) # true, and both variables are set to 1 if (( my $x = f0() ) && ( my $y = f1() )) # false, $x is set to 0, $y is undef if (( my $x = f0() ) || ( my $y = f1() )) # true, $x is set to 0, $y is set to 1 if (( my $x = f1() ) || ( my $y = f1() )) # true, $x is set to 1, $y is undef
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: AND OR
by davidrw (Prior) on May 14, 2006 at 14:19 UTC | |
by tye (Sage) on May 14, 2006 at 16:29 UTC |