foreach loops

The foreach loop iterates over a list value and sets the control variable (var) to be each element of the list in turn:

foreach var (list) {
    ...
}

Like the while statement, the foreach statement can also take a continue block.

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.