'
==' is for numerical comparisons, which means both arguments will be converted to numbers before the actual comparison happens.
That's why you get warnings if the conversion fails ("foo" isn't numeric) or one of the values is undef.
The reason why perl has both stringwise and numerical comparisons,, is because you're not really supposed to know whether a scalar contains a string or a number. A value "1" is thought of as being equivalent to just 1. Other languages that have only one equality test operator, like Javascript, VB, and PHP, can cause bugs because it tries to infer what you mean from the type of variable. Which could be different from what you think. Ditto with the concatenation operator, . vs. +.
p.s. In the CB, jkva seems to have had some doubt on why == is called a "binary operator". The reason is because == has 2 arguments, plain and simple (bi == 2). Likewise, ! is an "unary operator" (un == 1), and ?: is a "ternary operator" (ter == 3).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.