2.2.2 Compound Statement

A compound statement is usually constructed by using special words called keywords, conditional or logical expressions and blocks. We see what blocks are shortly. Depending on the programming language under consideration, what is true and what is false may be interpreted differently. For example, the following is a compound statement called the if statement in Perl.

if ($temperature >= 100){
print "It is scorching hot!\n";
}

It has the keyword if, a parenthesized logical expression, and a block delimited by { and } containing only one statement. if is a reserved keyword signaling a specific type of compound statement. There are many types of compound statements that Perl allows. Examples of compound statements are blocks, conditional statements, and loop or iterative statements.