[Rt-commit] r9405 -
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Tools/Elements
ruz at bestpractical.com
ruz at bestpractical.com
Mon Oct 22 18:09:15 EDT 2007
Author: ruz
Date: Mon Oct 22 18:09:14 2007
New Revision: 9405
Modified:
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Tools/Elements/GetEmailFromIP
Log:
* $whois->query can return undef
* refactor code a little
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Tools/Elements/GetEmailFromIP
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Tools/Elements/GetEmailFromIP (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Tools/Elements/GetEmailFromIP Mon Oct 22 18:09:14 2007
@@ -33,17 +33,21 @@
use Net::Whois::RIPE;
my $whois = Net::Whois::RIPE->new( $server, Debug => 1 );
-if ($whois) {
- my $query = $whois->query($q);
- if ($query->can($field)) {
- $$address = $query->$field();
- }
- else {
+unless ( $whois ) {
+ $$error = "Unable to connect to whois server '$server'";
+ return;
+}
+
+my $query = $whois->query($q);
+unless ( $query ) {
+ $$error = "Unable to connect to whois server '$server'";
+ return;
+}
+unless ($query->can($field)) {
$$error = "Whois server response did not include field '$orig_field'";
- }
-} else {
- $$error = "Unable to connect to whois server '$server'";
}
+
+$$address = $query->$field();
</%INIT>
<%ARGS>
More information about the Rt-commit
mailing list