%dns_check = ("address" => "ip"); while ( ($key, $value) = each %dns_check) { $found_addr = gethostbyname($key) or die "Error $!\n"; $found_addr = inet_ntoa(inet_aton($key)); print "IP found is: $found_addr ", "\n"; }