Looping Directives: foreach, for
Learn about the foreach and for looping directives.
The looping directives
Perl provides several directives for looping and iteration.
The foreach and for directives
The foreach-style loop evaluates an expression that produces a list and executes a statement or block until it has exhausted that list:
Press +  to interact
Perl
foreach (1 .. 10) {say "$_ * $_ = ", $_ * $_;}
This example uses ...
 Ask