Personally, I don't like having to perform the same test ($tries == $max_tries) twice.
my $max_tries = 5; foreach $item (@array) { my $tries = 0; while (!some_test($item)) { die "Failed $tries times, aborting" if ++$tries == $max_tries; print "Failure: $item, trying again after sleep\n"; sleep 10; } print "Success: $item\n"; }
In reply to Re^2: Back step in foreach loop
by ikegami
in thread Back step in foreach loop
by rosenrosen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |