== forces scalar context. Both 1 and 2 are treated as decimal integers. Obviously they are not the same.
print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});
| [reply] [d/l] |
Uhm, yeah. That was a rhetorical question type thing in response to swampyankee's suggestion that since undef and 0 are both false then it logically follows that undef == 0 should also be true. I was just giving an example where boolean equality is not equivalent to numeric equality.
| [reply] |
No, what it means is that is_true(1) == is_true(2), where is_true is something like sub { $_[0] ? 1 : 0 }
| [reply] [d/l] [select] |
It does mean that 1 && 2 evaluates to true. And, were Perl to have Fortran-style logical comparison operators (.EQV. and .NEQV.; this gives me an idea for an Acme module...), 1 eqv 2 would evaluate to true.
Every language has its little corners which may not be that well thought out; undef& == 0 evaluating to true may be one of them (00 evaluating to 1 is probably another). It is consistent, and arguably reasonable, behavior, although it's just as sensible, and arguably more reasonable, to have undef behave like NaN and not be comparable to anything, even itself (NaN == NaN and NaN != NaN are both false in most languages).
emc
Information about American English usage here and here.
Any Northeastern US area jobs? I'm currently unemployed.
| [reply] |