> Does NEXT work inside SWITCH statements?

No.  It's a bug.

Here's the general structure of the code that is generated:

    # FOREACH
    while (! $error) {
        # SWITCH
        do {
            SWITCH: {
                # CASE
                if ( ... ) {
                    # NEXT
                    ($value, $error) = $list->get_next();
                    next;
                }
            }
        }
        ($value, $error) = $list->get_next();
    }

The NEXT causes the loop variable to be bumped (correct), but ends up
at the end of the SWITCH block (incorrect).

One fix to Directive.pm is to add an explicit block name for the
loop, and to use this name in the next (this should still work in
nested loops):

    LOOP: while (! $error) {
                ...
                next LOOP;
    }

Craig


Reply via email to