On Wed, May 01, 2002 at 04:14:49PM +0100, Dave Mitchell wrote:
> In the true sprirt of perverseness, why not make loops into functions that
> return the number of iterations taken. Then you can have
> 
>     loop {
>       ....
>     }
>     or die "loop not taken\n";
> 
> ;-)

Right. This was my initial idea; the else/otherwise stuff is too confusing as
it hints too strongly to if blocks. So

  loop { ... } or print "Sorry\n";
  
  loop {
      ...
  }
  or {
      print "Sorry\n";
      # do other stuff
  }

  loop { ... } and print "Done\n";

The point is that it gives you the option to easily do something after the
loop with the knowledge of whether the loop failed or succeeded, and it makes
more grammatical sense, too. (loop/else doesn't.)

>:)
marius.

> -- 
> A walk of a thousand miles begins with a single step...
> then continues for another 1,999,999 or so.

Reply via email to