![]() |
|
Syntactic Confectionery Delight | |
PerlMonks |
Re^3: The True but Zero value?by Athanasius (Archbishop) |
on Mar 21, 2016 at 03:35 UTC ( #1158394=note: print w/replies, xml ) | Need Help?? |
Hello Marshall, 0E0 is more often seen, but this works the same way. Yes, but only when it appears as a string; when it appears as a number, it is zero and false:
Output:
The string '0' is documented as special: it is zero and false. Other strings are true1 regardless of their numerical values. It appears that the isn't numeric warning applies only when the numerical conversion is not “pure” (because the string contains non-numeric characters). It seems strange that this behaviour is so poorly documented. The '0 but true' special case is not mentioned in perlsyn#Truth-and-Falsehood. My experiments suggest that this special string must be character-for-character exact for the special behaviour to apply. For example, '0 but true ' (note the extra space at the end) still generates an isn't numeric warning. Update: 1Except the empty string, '', which is also documented to be false. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|