SPUG: 0E0 Re: "Boolean" return values
David Dyck
david.dyck at fluke.com
Tue Oct 14 09:27:12 PDT 2008
On Tue, 14 Oct 2008 at 08:56 -0700, charles.e.derykus at ... wrote:
>> Indeed, '0E0' (scientific exponent notation floating point) evaluates
> to zero... but is not false.
>
> Perl even provides its own "lipstick for a pig" in the spirit of '0E0':
>
> $ perl -wle 'print "true" if "0 but true"'
> true
>
> $ perl -wle 'print "0 but true" + 1'
> 1
Another place where perl (ever since perl1) uses the
"E0" special flag is in the ".." range operator
(The "0 but true" seems to have started around perl3)
see perldoc perlop:
Range Operators
Binary ".." is the range operator, ....
... The final sequence number in a range has the string "E0"
appended to it, which doesn't affect its numeric value, but gives
you something to search for if you want to exclude the endpoint. ...
More information about the spug-list
mailing list