in reply to Re: confused: string and number comparison
in thread confused: string and number comparison
I asked the question as it was not clear for me why comparing 0 to a non-empty string returns true. The other fact I came along during my test for this issue was that undef == 0 also returns true.
After our discussion and bit more thinking my understanding changed to: the string or undef doesn't represent any (other) number so the '==' operator treats this as '0'. The only other possibility would be always return false in case one or both options are not numeric. Current behavior is surprising for me but maybe it has also some advantages.Perhaps a perl guru spend some seconds talking about it if he comes here...
|
|---|