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:
“The honor my country shall never be stained by an apology from me for the statement of truth and the performance of duty; nor can I give any explanation of my official acts except such as is due to integrity and justice and consistent with the principles on which our institutions have been framed.”
—Andrew Jackson (17671845)