I don't want 'return' to have any meaning other than returning from a 
subroutine, nor do I want the word 'goto' to appear in my code except for 
goto &sub.

How about we just allow last, redo, next to take another argument, which 
provides the final or intermediate value of a block whose value is being 
used?  First argument can be undef for nearest enclosing block.  Yes, it 
looks a little weird, but this is a relatively uncommon thing to want to do 
and not worth IMHO creating a new keyword for, so why shouldn't it look 
weird.  Hence:

$foo = do { last undef, $bar if baz($bar) } while $bar++;

@list = grep { last undef, '' if /sentinel/; baz($_) } @thingies;

@list = grep { next undef, 'okay' if /sentinel/; baz($_) } @thingies;

etc.  I'm assuming that one would want to retain the capability to last, 
next etc out of an outer enclosing labelled loop, otherwise I'd just 
propose overloading the one argument and say that if it's a reference, take 
the thing it refers to as the value and exit/continue the nearest enclosing 
loop.
--
Peter Scott
Pacific Systems Design Technologies

Reply via email to