Loop constructions help organize repeated actions. There are a few different options in Perl 6 for creating a loop. Let's start with the one that is similar to traditional loops in C style.
Using loops
The loop cycle
The loop keyword expects three elements to control the number or repetitions of the loop body. Consider the following code snippet:
loop (my $c = 0; $c < 5; $c++) {
say $c;
}
In this example, $c is the counter of the loop iterations. This variable is declared and initialized immediately after the loop keyword—my $c = 0. The body of the loop is executed if the condition $c < 5 is True. After the iteration, the $c++ statement is executed, which increments the counter, and the cycle repeats....