On Fri, Jun 16, 2017 at 11:11 PM, Gabor Szabo <[email protected]> wrote:
> I probably would not say "restart" the loop.
>
>
There is a statement for that, "redo" restarts the loop without updating
the value.
my $true_count = 0;
loop (my $i = 1; $i < 10; $i++) {
last if ++$true_count == 6;
say "\$true_count==$true_count, \$i=$i";
redo if $i %% 2; # if it can be divided by two go restart this
iteration
say "Did not reoo";
}
prints
$true_count==1, $i=1
Did not reoo
$true_count==2, $i=2
$true_count==3, $i=2
$true_count==4, $i=2
$true_count==5, $i=2
-y