[prev] [index] [next]

Control Structures (cont)

Example of fine-grained loop control:

OUTER:
while (i < 1000)
{
    INNER:
    for ($i = 0; $i < 99; $i++)
    {
        last OUTER if $i > 90;   # terminates both loops
        $i += 3;
        next if $i > 80;         # next iteration of INNER
        if ($i > 70) { next; }   # next iteration of INNER
        $i += 4;
        redo if $i < 70;         # next iteration of INNER
        next OUTER if $i == 42;  # next iteration of OUTER
     }
}