in reply to Back step in foreach loop
(untested)my $max_tries = 5; foreach $item (@array) { my $tries = 0; while(some_test($item) and $tries++ < $max_tries) { print "Failure: $item, trying again after sleep\n"; sleep 10; } if( $tries == $max_tries){ die "Failed $tries times, aborting"; }else{ print "Success: $item\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Back step in foreach loop
by ikegami (Patriarch) on Nov 11, 2008 at 02:00 UTC |