On Wed, Aug 01, 2001 at 01:56:59AM +0200,  Marc A. Lehmann  wrote:
> On Wed, Aug 01, 2001 at 01:41:59AM +0200, Abigail <[EMAIL PROTECTED]> wrote:
> > > not in my copy of perlsyn (from perl-5.7.2).
> > Lines 113, 120, and 255 of my copy of perlsyn.pod in perl-5.7.2.
> 
> Sorry, still not in my copy of perlsyn.pod from 5.7.2. Although there is
> something very similar I overlooked the last time when looking for it. The
> example in line 120 (the other examples talk about next) says:
> 
>    For C<last>, you have to be more elaborate:
> 
>        LOOP: { 
>                do {
>                    last if $x = $y**2;
>                    # do something here
>                } while $x++ <= $z;
>        }
> 
> Not reading the context, I admit that I don't understand why you have to
> be "more elaborate" for last, but perlsyn actually says that your example
> does not work:
> 
>    You can always put another block inside of it (for C<next>) or around
>    it (for C<last>) to do that sort of thing.  For C<next>, just double
>    the braces:

Well, that's because the examples used use statement modifiers.

If you have:

     do {{EXPR; last}} while EXPR;

The last just out of the inner loop - but not out of the do {}.
If you reverse the block and the do{}, the last jumps out of the
outer block, and hence the do{}.

     do {{EXPR; last}}   # No modifier.

works fine - a short test will show you.

> I think it's quite arrogant from you to tell people: "straight from
> the docs" when, in fact, the documentation says something completely
> different.

Minor and irrelevant details. The principle, a nest of a bare block
and a compound block to be able to use loop control is straight from
perlsyn.pod. Not once, not twice, but three times.

Straight from the docs doesn't mean "you can cut-and-paste" - it just
means you find the principle explained clearly - without having to
construct it from smaller blocks.


Abigail

Reply via email to