http://www.perlmonks.org?node_id=980677


in reply to Re: ||= (poorly documented?)
in thread ||= (poorly documented?)

There is a rather strange thing that can happen in Perl.
It is possible for Perl to return a "true", "zero" value.
It does this by returning the string "0E0": 0 * 10**1 =0 numerically, but that evaluates to "true" in a logical sense.
This works because there are only two strings which evaluate as false in Perl: "" and "0".

Any other string which begins with one or more zeroes followed by a non-digit character will by logically true (since it's not one of the two false strings) while still having the value 0 when evaluated as a number. This actually will also work with strings that start with a non-numeric character (true as a boolean, 0 as a number), but, if warnings are enabled (as they generally should be), it will complain that "Argument "..." isn't numeric" if you try to use it as a number.

Aside from "0E0", the other string I often see used for this purpose (I'm not sure which is more common) is "0 but true".