sub try(&@) { my $job = shift; my $retries = shift || 1; my $timeout = shift || 1; my $res; while (!$res) { $res = &$job; } continue { return unless --$retries; sleep $timeout; } return $res; } try { get_web_page() } 10, 10 or die "Can't get page";
In reply to retry code snippet by ccn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |