http://www.perlmonks.org?node_id=758424

edatawiz has asked for the wisdom of the Perl Monks concerning the following question:

I am using Net::Whois::Raw.

I have enabled the following:
$Net::Whois::Raw::OMIT_MSG = 1;
$Net::Whois::Raw::TIMEOUT = 10;
$Net::Whois::Raw::CHECK_FAIL = 1;
I call the module by my $dominfo = whois($list1) It often fails if the url is in unknown format or at times says whois.crsnic.net: Unknown error: whois.crsnic.net:43 at C:/Perl/site/lib/Net/Who is/Raw.pm line 235

eval {...} called at C:/Perl/site/lib/Net/Whois/Raw.pm line 232
This error "
eval {...} called at C:/Perl/site/lib/Net/Whois/Raw.pm line 232
" is what I often see.
How do I make sure the code skips such errors and continue checking the next domain without dying.
Vishy

Replies are listed 'Best First'.
Re: Error handle Net::Whois::Raw
by Anonymous Monk on Apr 18, 2009 at 09:43 UTC
    my $dominfo; my $onesuccess = eval { $dominfo = whois($list1); 1}; if( $onesuccess ){ ... } else { log("failed for { $list1 } : $@"); next; }
      my $dominfo; next unless eval { $dominfo = whois($list1); 1 }; ...