for loops
The for
loop has
three semicolon-separated expressions within its parentheses.
These three expressions function respectively as the
initialization, the condition, and the reinitialization
expressions of the loop. The for
loop can be defined in terms of the
corresponding while
loop:
for ($i = 1; $i < 10; $i++) { ... }
This is the same as:
$i = 1; while ($i < 10) { ... } continue { $i++; }
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.