Every now and then I have this discussion with people at work that involve Perl's 
ideas of boolean truth. I usually break it down like this:

In Perl5, the following values are FALSE: undef, '0', 0, and ''.
 
Anything not in that list is considered TRUE in a boolean context. That means that 
Perl5 has some notions of truth that confuse some folk. I mean, I can understand "00" 
being true, even if it seems a little odd to me personally, but "\0"??? How is a 
single null byte *true*?

Okay, so it's binary data. So is "0" and 0, if you look at it that way. I realize the 
internal representations are different, but the programmer shouldn't have to care 
about that. I just figure that if my bit of $data contains one byte, and I'm checking 
that $data for boolean truth, I'd expect a null to be false, as would ba-zillions of C 
programmers (from which backgroud I came). I know we aren't trying so hard to imitate 
C behavior anymore, but still, doesn't this violate the principle of least surprise?

So my question is this, with apology for the ramble....
aside from P6's other changes, is a single null byte of binary data still going to 
register as TRUE, or will it now be what seems to me the more sensible FALSE?

Paul


 

*****
The information transmitted is intended only for the person or entity to which it is 
addressed and may contain confidential, proprietary, and/or privileged material.  Any 
review, retransmission, dissemination or other use of, or taking of any action in 
reliance upon, this information by persons or entities other than the intended 
recipient is prohibited.  If you received this in error, please contact the sender and 
delete the material from all computers. 113

Reply via email to