In Perl, Truth is defined as follows:
$a; # FALSE (not yet defined) $a = 1; # TRUE $b = 0; # FALSE $c = ""; # FALSE $d = 'true'; # TRUE $e = 'false'; # TRUE (watch out! "false" is a nonemty string) $f = ' '; # TRUE (a single space is non-empty) $g = "\n"; # TRUE (a single newline is non-empty) @h = (); # FALSE array $i = 0.0; # FALSE (converts to string "0") $j = '0.0'; # TRUE (watch out! The string "0.0" is not the same as "0") |
$a = 4 == 1+3; print "The answer is $a","\n"; |
The answer is 1.
|
| Contents |
Next |