Perl until Loop
The until statement repeatedly executes a statement or statement group while the given condition is false.
until can be translated as"unless"。
Syntax
The syntax format is as follows:
until(condition)
{
statement(s);
}
Here, statement(s) can be a single statement or a block of statements.
condition can be any expression. The loop is executed when the condition is false. When the condition is true, the program flow continues to the next statement immediately following the loop.
Flowchart
In the diagram,untilThe key point of the loop is that the loop may not execute even once. When the condition is true, the loop body is skipped and the next statement immediately following the while loop is executed directly.
Example
In the program, the loop body is executed when the variable $a is less than 10, and the loop exits when the variable $a is greater than 10.
Executing the above program produces the following result:
a 的值为 : 5 a 的值为 : 6 a 的值为 : 7 a 的值为 : 8 a 的值为 : 9 a 的值为 : 10Other Extensions
Perl Loops