Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: OEO, a zero that evaluates to true?

by n3dst4 (Scribe)
on Jan 08, 2002 at 21:40 UTC ( #137191=note: print w/ replies, xml ) Need Help??

in reply to OEO, a zero that evaluates to true?

Blakem pointed you to a good resource, but basically you've hit Context. In Perl, when you:

Do a mathsy thing to a string (like '0E0' or 'oink' or '57Fred')
Any digits at the start are taken as the value and the rest is lost. So (5 + '0E0') == (5 + '0') == (5 + 0) == 5
Do a stringy thing to a string
It stays the way it is
Do a neutral thing to a string, like checking for truth
It again gets left the way it is.
So in your case, '0E0' is true as a string, because it's neither empty nor just the string '0', but false as a number because it gets whittled down to the value 0 (the digits at the start).

Comment on Re: OEO, a zero that evaluates to true?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://137191]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2015-11-28 22:11 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls