develooper Front page | perl.perl6.language | Postings from November 2003

Re: Control flow variables

Thread Previous | Thread Next
From:
Seiler Thomas
Date:
November 18, 2003 14:41
Subject:
Re: Control flow variables
Message ID:
20031118224046.50827.qmail@onion.perl.org
Damian Conway wrote:

>      push @moves, [$i, $j];
>      for 0..6 -> $t {
>          if abs(@new[$t] - @new[$t+1]) > 3 {
>              pop @moves;
>              last;
>          }
>      }
>
>

Indeed, an elegant way around the problem.
So... lets call a function instead:

    my $is_ok = 1;
    for 0..6 -> $t {
        if abs(@new[$t] - @new[$t+1]) > 3 {
            $is_ok = 0;
            last;
        }
    }
    if $is_ok {
        yada()  # has sideeffects...
    }

(wrote many such constructs for cgi sanity
checks and always found it mildly annoying)

regards
thomas

--
Imagination is more important than knowledge [Einstein]


begin 666 wink.gif
M1TE&.#EA#P`/`+,``````+^_O___````````````````````````````````
M`````````````````````"'Y! $```$`+ `````/``\```0T,$@):ITX5,'Y
MQ4 G>E,XC@`EF.MJIJSEQ>PI;C9:YZYGOQK?C12<R8C%7P;7^60TEA0F`@`[
`
end


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About