Perl until loop
Perl until cycle / h1>
In the given conditions until the statement is false, the statement or group of statements repeatedly performed.
grammar
The syntax is as follows:
until(condition) { statement(s); }
Here, statement (s) may be a single statement, it can also be a block composed of a few statements. condition can be any expression, when the condition is false the loop.
When the condition is true, program flow will continue with the next statement followed the loop.
flow chart
Chart, key pointsuntilthe loop is a loop may not execute. When the condition is true, the loop body will skip directly to the next statement immediately while loop.
Examples
#!/usr/bin/perl $a = 5; # 执行 until 循环 until( $a > 10 ){ printf "a 的值为 : $a\n"; $a = $a + 1; }
Program in the variable $ a is less than 10 loop body is executed, the variable $ a is greater than or equal to 10, the loop is exited.
The above program, the output is:
a 的值为 : 5 a 的值为 : 6 a 的值为 : 7 a 的值为 : 8 a 的值为 : 9 a 的值为 : 10