Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^3: True or False? A Quick Reference Guide

by xdg (Monsignor)
on Sep 29, 2005 at 19:16 UTC ( #496214=note: print w/replies, xml ) Need Help??

in reply to Re^2: True or False? A Quick Reference Guide
in thread True or False? A Quick Reference Guide

Yes, though that's a little more logical, since perldata specifies that numbers can be written in scientific notation in a form like 12.34E-10. So 0E0 is just a number, and "0E0" is a string that has length (is true) but evaluates as 0E0, which is zero (false). If you want to think about it the other way, '0' is a special case of a string that has length but is treated as false.

What I find interesting about "0 but true" is that it more clearly highlights to a reader that something unusual is going on than something like "0.0" or "0E0" -- and to such an extent that it was excepted from the usual warnings so as to make it easier to use that way. Anyone know the history of this? Or what version of Perl it first appeared in? (timtoady, are you out there?)


Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re^3: True or False? A Quick Reference Guide

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://496214]
[james28909]: hi, im james, and i am bat shit crazy. xD
[james28909]: crazy or genius....
[Eily]: hi bat shit crazy, I'm eily
[LanX]: hello James
[james28909]: lol
[james28909]: i honestly didnt thin kanyone was going to respond, or was even paying attention :l
[Eily]: well if you say something like that someone has to pay attention by law
[Eily]: Murphy's law to be precise
LanX Anonymous Monks meeting
holli brings cookies to the meeting

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2017-12-13 17:42 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (373 votes). Check out past polls.