my $max = 3; retry( sub { die "failure" } ); sub retry { my $sub_ref = shift; my $try = 0; ATTEMPT: { eval { $sub_ref->(); }; if ( $@ and $try++ < $max ) { warn "Failed try $try, retrying. Error: $@\n"; redo ATTEMPT; } } if ($@) { die "failed after $max tries: $@\n" } }
In reply to Re: Re: retrying an action that could fail
by perrin
in thread retrying an action that could fail
by perrin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |