Go to the first, previous, next, last section, table of contents.

Simple Statements

The only kind of simple statement is an expression evaluated for its side effects. Every simple statement must be terminated with a semicolon, unless it is the final statement in a block, in which case the semicolon is optional. (Semicolon is still encouraged there if the block takes up more than one line).

Any simple statement may optionally be followed by a single modifier, just before the terminating semicolon. The possible modifiers are:

if EXPR
unless EXPR
while EXPR
until EXPR

The if and unless modifiers have the expected semantics. The while and until modifiers also have the expected semantics (conditional evaluated first), except when applied to a do-BLOCK or a do-SUBROUTINE command, in which case the block executes once before the conditional is evaluated. This is so that you can write loops like:

do {
        $_ = <STDIN>;
        ...
} until $_ eq ".\n";

(See the do operator below. Note also that the loop control commands described later will NOT work in this construct, since modifiers don't take loop labels. Sorry.)


Go to the first, previous, next, last section, table of contents.