如果它只是您想要存储的任意 (quad-)A 记录,您也可以尝试这样的操作:
use strictures;
use Perl6::Take qw(gather take);
use Socket 1.96 qw(getaddrinfo getnameinfo AF_INET6 AF_INET SOCK_STREAM NI_NUMERICHOST NIx_NOSERV);
# require 1.96 or better for NIx_NOSERV, ships with Perl 5.14
⋮
my $host = $mech->url->host;
my @ip = gather {
for my $family (AF_INET6, AF_INET) {
my ($err, @addrinfo) = getaddrinfo($host, 'http', { family => $family, socktype => SOCK_STREAM });
warn "Cannot getaddrinfo - $err" if $err;
for my $ai (@addrinfo) {
my ($err, $ipaddr) = getnameinfo($ai->{addr}, NI_NUMERICHOST, NIx_NOSERV);
warn "Cannot getnameinfo - $err" if $err;
take $ipaddr;
}
};
};