From: Tom Christiansen [mailto:[EMAIL PROTECTED]]
> From: Garrett Goebel
> > There seems to be some general consensus that some people
> > would like to be able to short-circuit functions like
> > grep. Do you see no need for the code
> > block equivalent of C<next>/C<last>/C<redo>?
>
> What, you mean like
>
> Loop controls don't work in an C<if> or C<unless>, either, since
> those aren't loops. But you can always introduce an extra set
> of braces to give yourself a bare block, which I<does> count
> as a loop.
>
> if (/pattern/) {{
> last if /alpha/;
> last if /beta/;
> last if /gamma/;
> # do something here only if still in if()
> }}
Totally accurate, but it still doesn't allow me to short-circuit C<grep> and
return a value.
The only way I know to do that currently requires:
eval { grep { $_ ==1 and die "$_\n" } (1..1_000_000) };
chomp($@);
my $found = $@;