in reply to What is true and false in Perl?
The oft-cited list of values considered false is:
I did actually manage to find another value that Perl treats as false:
-0.0
You can see its interesting behaviour here:
perl -E'say(-0.0 eq 0?"eq 0":"ne 0"); say(-0.0?"true":"false");' ne 0 false
Note that it's false but not (stringy) equal to zero.
This does vary between Perl versions. The behaviour documented above exists between Perl 5.6.x to 5.12.x (obviously you need to use print instead of say before Perl 5.10) and perhaps earlier. But in Perl 5.14.x, -0.0 is (stringy) equal to 0.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: What is true and false in Perl?
by Anonymous Monk on Oct 17, 2012 at 17:07 UTC | |
by tobyink (Canon) on Oct 18, 2012 at 02:26 UTC | |
by tye (Sage) on Oct 18, 2012 at 03:50 UTC | |
by amartyaj (Initiate) on Nov 22, 2013 at 18:00 UTC | |
by davido (Cardinal) on Nov 22, 2013 at 18:11 UTC | |
by amartyaj (Initiate) on Nov 22, 2013 at 19:35 UTC | |
by jdporter (Paladin) on Oct 17, 2012 at 19:43 UTC | |
by Anonymous Monk on Oct 17, 2012 at 23:40 UTC | |
by jdporter (Paladin) on Oct 18, 2012 at 15:25 UTC |