in reply to if logic OR parentheses problem
You'll notice that $atob is -2.5, $btoc is -0.5, and $atoc is -3.print join ' ', $atob, $btoc, $atoc, "\n";
For clarity, I'd also use the abs function rather than nested logic:
And like the other monks suggested, use strict; and use warnings; will point out where your code could run into problems. There is also use diagnostics; for an extra helping of advice.if (abs $atob > 1 && abs $btoc > 1 && abs $atoc > 1 ) { print OUTFILE "DIFF > 1 all three\n"; $matrixflags[$row - 4][$i] = 1; $matrixflags[$row - 3][$i] = 1; $matrixflags[$row - 2][$i] = 1; } elsif (abs $atob > 1 && abs $btoc < 1 && abs $atoc > 1 ) { print OUTFILE "DIFFA > 1 $atob $atoc $btoc\n"; $matrixflags[$row - 4][$i] = 1; $matrixflags[$row - 3][$i] = 0; $matrixflags[$row - 2][$i] = 0; } elsif ( ... ) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: if logic OR parentheses problem
by johngg (Canon) on Oct 26, 2007 at 15:40 UTC | |
by gamache (Friar) on Oct 26, 2007 at 16:09 UTC |