SPUG: 0E0 Re: "Boolean" return values

Fred Morris m3047 at inwa.net
Tue Oct 14 08:37:22 PDT 2008


Indeed, '0E0' (scientific exponent notation floating point) evaluates to 
zero... but is not false.

You can argue about the sense or ideosyncracy of this (is sense always orderly 
and composed, and does ideosyncratic == nonsense? ahh philosophy!) but it is 
put to practical use.

When you use DBI->connect()->do() the number of records affected is returned 
as the function value if the operation succeeds... otherwise the return value 
tests false. When zero records are affected (but the operation was deemed 
successful) '0E0' is returned so that sense is preserved and the operation 
doesn't return false.

Does DBI have its lipstick on straight, or is trying to enforce strict type 
checking on built-in types lipstick on a pig? Does it matter to the pig 
(other than to annoy it, what with all the fussing about), or is it solely 
something done for the beholder?

On Tuesday 14 October 2008 08:08, Michael R. Wolf wrote:
> [...]
> In practice, most strings are true.  I know of only 3 false strings:
>   1. '', the empty string
>   2. '0', the string containing only a single zero
>   3. "\000", the ASCII NUL character (AKA chr(0)).

--

Fred Morris
http://www.inwa.net/~m3047/contact.html



More information about the spug-list mailing list