> @passed = grep { 2 > $_ and last } (1, 2, 3, 2, 1);
>
> I believe that unless used with a label, if someone were to use
> last within a grep or map block, then further processing for that
> element of the list which grep is working on would be skipped, and
> it would continue with the next element.
>
> would leave
> @passed = (1, 2)
I believe the above would leave:
@passed = ();
since on the first call to the block 2 > 1 is true, so the C<last> is
executed, which terminates the C<grep> immediately.
> instead of the current behaviour which would be
> @passed = (1, 2, 2, 1)
That's not the current behaviour.
With the C<last> you either get an exception or an exit from the surrounding
block (and in either case @passed is not reassigned at all).
If you meant "current behaviour without the C<last>", that's still
not right. Without the C<last> the current behaviour leaves (1,1)
in @passed.
> We are already advised not to use last within eval {}, sub {}, do
> {}, grep {}, and map {}, but this might break some obfuscated code
> which depends on it. I'm not to sure how this could be handled in a
> Perl 5->6 translation...
Have p52p6 name *every* block and label *every* C<next>, C<last>, and C<redo>.
Damian