September 2002
Intermediate to advanced
544 pages
13h 6m
English
In the expressions used by the conditional statements and while loops I described, various expressions were evaluated to determine how the flow of the program will work. The simplest expressions just evaluate a value and determine whether it is considered to be true or false. Any non-zero number or non-empty string is true; zero, empty strings, and the value undef are false. A simple if statement might evaluate a variable by itself, like this:
$var = undef;
if ($var) {
print "The expression is true.\n";
} The code inside that if statement would not be executed because undef is always considered to be false. Just as you can evaluate a variable or static value as an expression, you can also evaluate the value returned by a subroutine. ...
Read now
Unlock full access