{ do { ... if ($retries > 3) { print "3 attempts are failed.\n"; last; } } while ($f_cnt > 1); }