in reply to == and != don't work as expected
$ perl -lwe 'print "two" == "two"' Argument "two" isn't numeric in numeric eq (==) at -e line 1. Argument "two" isn't numeric in numeric eq (==) at -e line 1. 1
So it returns a true value.
But that's because Perl tries to convert strings to numbers in order to do the numeric conversion. "two" has no obvious numeric equivalent so Perl uses zero.
Perl rarely dies because it finds data in the wrong format. It tries hard to do what it thinks you want to do. This is usually seen as a feature.
If it's essential that your program only compares actual numbers, then you should check them before you do the comparison.
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|