in reply to confused: string and number comparison
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 | |
by lostjimmy (Chaplain) on Mar 24, 2011 at 13:00 UTC |