in reply to Re^2: loop surprise
in thread loop surprise
my $condNum = 0; for $condNum ( 1 .. 10 ) { forceSituation( $conditions[condNum] ); my $result = measureSituation(); ...; last if $result->is_error(); ... } datalog( value => $condNum, ...); ...
But in that case, why not use a C-style loop
(as suggested here)?c:\@Work\Perl\monks>perl -wMstrict -le "use constant N_MAX => 10; ;; my $nCond; ;; CONDITION: for ($nCond = 1; $nCond <= N_MAX; ++$nCond) { print $nCond; last CONDITION if $nCond >= 3; } ;; print qq{only made it to condition $nCond} if $nCond < N_MAX; " 1 2 3 only made it to condition 3
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: loop surprise
by pryrt (Abbot) on Apr 03, 2018 at 19:08 UTC | |
by choroba (Cardinal) on Apr 03, 2018 at 20:23 UTC | |
by pryrt (Abbot) on Apr 03, 2018 at 20:41 UTC |