[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] awww, no fun :(



>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:

>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
RLS> That's to be able to write loop controls like:

RLS> sub last_OUTER_if_int { last OUTER; }

RLS> { local $SIG{INT} = 'last_if_int';

RLS> OUTER: while ($some_cond) {
RLS> ...
RLS> ...
RLS> ...
RLS> ...
RLS> }
RLS> }

RLS> There... now we break the loop on int, rather than break the program.

Uri> and that can be done with eval/die as well which is designed for things
Uri> like that. this escaping a loop using last in a sub is obscure at best
Uri> and definitely confusing. the fact that it warns and the eval/die
Uri> doesn't is a major reason to use the latter.

But the warnings were added fairly recently.  Larry told me directly
that last/next/redo are permitted from subs so that subs can be
used to implement named control-steps in a control structure.  Or at
least that was the original intent.  With the warning being triggered,
it's obviously not useful to warnings-enabled programs.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe