This is a simple example - but note that you might be seeing failures because the host you're querying win isn't fully-qualified..?
#!/usr/bin/perl
use strict;
use warnings;
use Net::DNS;
sub lookupHost
{
my( $host ) = ( @_ );
my @results;
my $res = Net::DNS::Resolver->new;
my $query = $res->search($host);
if ($query) {
foreach my $rr ($query->answer) {
push( @results, $rr->address ) if ( $rr->type eq "A" );
}
} else {
warn "query failed: ", $res->errorstring, "\n";
}
return( @results );
}
my @out = lookupHost( "google.com" );
foreach my $ip ( @out )
{
print "result: $ip\n";
}