SPUG: "Boolean" return values
Ronald J Kimball
rjk-spug at tamias.net
Tue Oct 14 08:18:45 PDT 2008
On Tue, Oct 14, 2008 at 08:08:37AM -0700, 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)).
>
There are only two false strings. "\000" is true.
This is explained very succinctly in the documentation, specifically
perlsyn:
Truth and Falsehood
The number 0, the strings '0' and '', the empty list "()", and
"undef" are all false in a boolean context. All other values are
true. Negation of a true value by "!" or "not" returns a special
false value. When evaluated as a string it is treated as '', but as
a number, it is treated as 0.
Ronald
More information about the spug-list
mailing list