Loop statements

If you need to execute a code block more than once, process known as iteration, you must use this type of Perl statements. A loop statement generally has an optional label and allows you execute the Perl statements enclosed by curly braces repeatedly, until an expression condition is met.

There are slightly differences between the basic Perl loop statements, and you can choose the one which is most appropriate for your task: for, foreach, while, do-while, until, do-until.

If you need more looping constructs than the basic loop statements provided by Perl, you can build your own.