http://qs321.pair.com?node_id=965353


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.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'