in reply to confused: string and number comparison

Why not just do a string equality comparison for both? You won't have the warning, and comparing '0' to 0 will give you the desired outcome.

Update: Just checking the value's truthiness should also suffice.

my @comparisons = ('0', 0, 1, '', '0 but true', 'abcd'); for (@comparisons) { if ($_) { print "keep [$_]\n"; } else { print "discard [$_]\n"; } }

Replies are listed 'Best First'.
Re^2: confused: string and number comparison
by dsheroh (Monsignor) on Mar 24, 2011 at 10:32 UTC
    Just checking the value's truthiness should also suffice.
    No, it won't. OP says that he's looking for cells containing either the single digit 0 or a single space, which is a true value. If he were looking for 0 or an empty string, then just checking truthiness would work, though.
      And that's what I get for not reading the spec thoroughly...