SPUG: Using last in non-loop blocks

Andrew Sweger andrew at sweger.net
Thu Apr 22 20:34:44 CDT 2004


On Thu, 22 Apr 2004, Jack Foy wrote:

> 'if' (and 'unless') blocks are the exception to that rule -- unlike all
> other blocks, they are not one-time loops.  (See page 123 of PP3.)
> That's because you often want to do something like this, and have it do
> the notionally right thing:
> 
> for (@lines) {
> 	if ($disaster) {
> 		clean_up();
> 		last;
> 	}
> 	normal_processing();
> }

Ooo. Nicely illustrated. I think I will keep my next/last/redo's to a
minimum or at least so they're painfully clear what they're doing. Thanks.

-- 
Andrew B. Sweger -- The great thing about multitasking is that several
                                things can go wrong at once.




More information about the spug-list mailing list