control flow repeat

Documentation for control flow repeat, assembled from the following types:

language documentation Control Flow

From Control Flow

(Control Flow) control flow repeat

Executes the block at least once and, if the condition allows, repeats that execution. This differs from while/until in that the condition is evaluated at the end of the loop, even if it appears at the front.

my $x = -42;
repeat {
    $x++;
} while $x < 5;
$x.say# OUTPUT: «5␤» 
 
repeat {
    $x++;
} while $x < 5;
$x.say# OUTPUT: «6␤» 
 
repeat while $x < 10 {
    $x++;
}
$x.say# OUTPUT: «10␤» 
 
repeat while $x < 10 {
    $x++;
}
$x.say# OUTPUT: «11␤» 
 
repeat {
    $x++;
} until $x >= 15;
$x.say# OUTPUT: «15␤» 
 
repeat {
    $x++;
} until $x >= 15;
$x.say# OUTPUT: «16␤» 
 
repeat until $x >= 20 {
    $x++;
}
$x.say# OUTPUT: «20␤» 
 
repeat until $x >= 20 {
    $x++;
}
$x.say# OUTPUT: «21␤» 

All these forms may produce a return value the same way loop does.