Anonymous user
Boolean values: Difference between revisions
→{{header|Perl}}
Line 537:
<lang perl>my $x = 0.0;
my $true_or_false = $x ? 'true' : 'false'; # false</lang>
</lang>▼
or
<lang perl>my $x = 1; # true
my $true_or_false;
if ($x) {
$true_or_false = 'true';
}else{▼
$true_or_false = 'false';▼
}
▲ $true_or_false = 'false';
▲}</lang>
The values in Perl that are false are: <tt>0</tt> (as a number (including <tt>0.0</tt>), or as the string <tt>'0'</tt>, but '''not''' the string <tt>'0.0'</tt>), the empty string <tt><nowiki>''</nowiki></tt>, the empty list <tt>()</tt>, and <tt>undef</tt>. Everything else is true. See [http://perldoc.perl.org/perlsyn.html#Truth-and-Falsehood perlsyn].
|