![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
if (EXPRESSION ) {
STATEMENTS;
}
if (EXPRESSION ) {
# executed if true
STATEMENTS;
} ELSE {
# executed if false
STATEMENTS;
}
if (EXPRESSION ) {
STATEMENTS;
} elsif {
STATEMENTS;
# optional additional ELSIF's
} else {
STATEMENTS;
}
This is the first time we've seen the { } (braces) used
outside the context of associative arrays. In addition to
denoting the key for an associative array, they are used to
mark of blocks of expressions. Any number of statements can be
part of the true or false portions of the IF ELSE, and the braces
are to enclose all of them. Unlike C, the braces are not
optional - requiring braces avoids the dangling else problem
Perl has no SWITCH statement - it can be imitated several ways, including using ELSIF for each possible case.
![]()
The National Center for Supercomputing Applications
University of Illinois at Urbana-Champaign
[email protected]
Last modified: June 19, 1997