Please explain what you mean by 'false positive'?
#!/usr/bin/perl use strict; use warnings; sub are_both_zero { my @array=@_; print "In the array (",join(', ',@array),"), "; if (!($array[0]+$array[1])) { print "both elements are zero.\n"; } else { print "at least one element is not zero.\n"; } } are_both_zero(3,-5); are_both_zero(3,0); are_both_zero(0,-5); are_both_zero(0,0); are_both_zero(3,-3);
Output:
In the array (3, -5), at least one element is not zero. In the array (3, 0), at least one element is not zero. In the array (0, -5), at least one element is not zero. In the array (0, 0), both elements are zero. In the array (3, -3), both elements are zero.
See also https://en.wikipedia.org/wiki/False_positive.
Alexander
In reply to Re^5: Check multiple array elements for a single condition
by afoken
in thread Check multiple array elements for a single condition
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |