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