Statement Modifiers
Perl also provides variants of the loop and conditional constructs that work on a simple statement (an expression evaluated for its side-effects) instead of a block:
statement if expr; statement unless expr; statement while expr; statement until expr; statement foreach list;The while and until modifiers test the controlling expression before executing the statement, just like their loop counterparts. However, they are not considered actual loops, so the loop control keywords next, last and redo cannot be used with them. They have special semantics when combined with the do keyword:
do block while expr; do block until expr;In these constructs, the condition is tested after the block is executed, so the block always executes at least once.
These modifiers cannot be nested, so the following is illegal
statement if expression for list; #ERRORand should be written as one of:
( expression ) and ( statement ) for list; for ( list ) { statement if expression } do { statement if expression } foreach list;Read more about this topic: Perl Control Structures
Famous quotes containing the word statement:
“Children should know there are limits to family finances or they will confuse we cant afford that with they dont want me to have it. The first statement is a realistic and objective assessment of a situation, while the other carries an emotional message.”
—Jean Ross Peterson (20th century)