Perl actually does warn you :
use warnings;
print "ho" if " 3 4 ">1;
Argument "" 3 4 " isn't numeric in numeric gt (>) at - line 1.
But if the string contains only leading or trailing spaces these are ignored. | [reply] [d/l] |
Updated on the suspicion that some (mis)read the previous wording as "snarky" when the question is merely intended to offer a parallel case to consider:
And if If you lived in a locale where the language was not your native tongue, you'd would you complain about how it differed from the language of your childhood?
In any case, you'll find a full and complete explanation of the output from your OP by reading about eq and == which do NOT perform the same test.
Update, repeating Annonymonk's above: eq is used when testing for string equality; ==, for numeric equality. Also as noted above, warn will let you know if you abuse ==. But the bottom line is, I think, that (in the best of all possible worlds) different languages can serve different needs and can, therefore, be expected to call upon the programmer to use approprikate methods for each.
Or, as others have suggested, your work (and your life) will be made easier if you understand your tools before attempting to use them | [reply] |