What is False?

The number 0, the string "0", the empty string, the empty list and undefined are all False.


Distinguishing Between the Empty String and 0


$a = '';
$b = 0;  

$result = $a eq '';  # TRUE
$result = $b eq '';  # FALSE
$result = length $a > 0; # FALSE


Distinguishing Between the Empty String and undef


$a = undef;
$b = '';  

$result = defined $a;  # FALSE
$result = defined $b;  # TRUE


<< Previous
Contents >> Next >>

Lincoln D. Stein, lstein@cshl.org
Cold Spring Harbor Laboratory
Last modified: Wed Oct 11 20:27:02 EDT 2000