Perl's until loop is used to loop through a designated block of code until a specific condition is evaluated as true. It is the logical opposite of the while loop.
until (expression) {
...
}
Perl starts the block by evaluating the expression inside the parenthesis. If the expression evaluates as false the code is executed, and will continue to execute in a loop until the expression evaluates as true. If the expression initially evaluates to true, the code is never executed and the code block will be skipped entirely.
The until loop process looks something like this when you break down each of the steps:
- Evaluate the initial expression.
- Does the test evaluate to false? If so, continue, otherwise exit the until loop.
- Execute the code block inside the until loop.
- Return to step 2.
