in reply to Re: Re: Anon. array of refs to a range generated list of scalars.
in thread Anon. array of refs to a range generated list of scalars.

Argh. Please don't use naked blocks with redo as loops, it's a nightmare to read. When I see a naked block, I expect to be looking at a private lexical scope, not an unadorned loop. If you need next, wrap the inner part with a naked block:
do {{ $bar; baz() or next; }} while $foo;
If you need last, wrap the whole thing:
{ do { $bar; baz() and last; } while $foo; }
Of course, if you need both, it does get awfully clumsy:
LOOP: { do {{ $bar; baz() or next; quux() and last LOOP; }} while $foo; }
In that case, and if you're so inclined then maybe in the other cases as well, I propose:
while(1) { $bar; baz() or next; quux() and last; }
At least it documents the loop nature of the block, even if the break condition is again somewhat hidden.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re4: Anon. array of refs to a range generated list of scalars.
by Hofmator (Curate) on Jan 18, 2003 at 20:31 UTC
    well, some people think differently ... and you could always mark the bare block with a label, clearly stating what you want to do
    LOOP: { # some code redo LOOP if condition; } # that's actually quite close to perl6 ;-) loop { # some code last unless condition; }

    -- Hofmator

      I tried to dredge up a heated discussion we had in the monastery maybe half a year ago, where the general consensus was that you shouldn't generally use naked blocks to loop like that, but came up empty handed after a dozen queries. :-/

      Makeshifts last the longest.