is quite correct. The only thing that is "special" about "0E0" is that it is documented in the Perl DBI. I have classic EE training so working with exponents is easy for me. However, I like the 0E0 idea and find it preferable to 0E5 or say "00" because a simple typo "0" gets us into another special case which might be hard to find in the code. This 0E0 values allows the DBI to express 2 ideas in one return value: 1) did it work or not? and 2)how many results were obtained.
I think we've "nailed this one". Here is summary of these special things:
- string "0", this would normally be "true" in a string context, because all non-null strings are
"true". However this is a special case
where it evaluates to "false" in a string context. So the special case code allows a more
intuitive behavior although technically an exception to the standard rules.
Of course this is numeric zero in
a numeric context as would be expected.
- string "0 but true", this is a special case where you can do math on this, e.g.. $val +=0; and no warning
will occur even with warnings enabled. Normally there would be a warning of $val is non-numeric at line x...". This of course
is "true" in a string context (all non-null are normally "true") and zero in a numeric context, just like it says.
This is not seen as often
as the next string ("0E0") which accomplishes the same thing.
- string "0E0", This could have been any string that evaluates to zero in a numeric context,
e.g. "00" or "0E5", However 0E0 is the documented return value in the DB for the
"0 but true" value. Since this is a valid number in a string context, no special code need
execute like in case (2).
Note: When I work with something that can return (2) or (3) and I make use of that, I add a comment to explain what is going on. Even if you know what is going on when you write the code, 3 years later, that might be "fuzzy".