< BACKCONTINUE >

B.5 Statements and Blocks

Programs are composed of statements often grouped together into blocks.

A statement ends with a semicolon (;), which is optional for the last statement in a block.

A block is one or more statements usually surrounded by curly braces; here's an example:

{
  $thousand = 1000;
  print $thousand;
}

Blocks may stand by themselves but are often associated with such constructs as loops or if statements.

< BACKCONTINUE >

Index terms contained in this section

; (semicolon), ending Perl statements
blocks
Perl
     statements
            blocks and
statements

© 2002, O'Reilly & Associates, Inc.