RETRY: while (my $n_attempt=0, my $callsign=<>) { $callsign = uc($callsign); # uppercase $callsign =~ s/^\s*//; # no leading spaces $callsign =~ s/\s*$//; # no trailing spaces does chomp() also.. next if $callsign eq ""; # skip NULL (blank lines)! my $callsign = (split(/,/,$callsign))[0]; #allow histogram format #w6oat,234 or just w6oat next if ($callsign =~ /^[a-zA-Z]\d{1}[a-zA-Z]$/); # like N7A # NO PROCESSING OF 1X1 US CALLSIGNS!!! print STDERR "working on $callsign\n" if DEBUG; my $req = GET "http://www.qrz.com/xml?s=$key;callsign=$callsign"; my $res = $ua->request($req); unless ($res->is_success) { $n_attempt++; print STDERR "$callsign ERROR: Try# $n_attempt of ".MAX_RETRY. " err:". $res->status_line ."\n"; sleep(1); redo RETRY if $n_attempt <= MAX_RETRY; print STDERR "$callsign ERROR: Try# $n_attempt of ". MAX_RETRY." FAILED: ". $res->status_line . "\n"; next; # skip this callsign and go to the next one. # This ain't gonna happen unless the QRZ server is # down. "if ($res->is_success)" means we got some kind # of response from the server. The QRZ server will # barf on about 1/2000 requests, hence the retries. }