sub lookup { my ($ldns, $fqdn) = @_; my ($error, $error_a); open DIG, "$dig \@$ldns $type $fqdn | " or die $!; while () { if (/;; ->>HEADER<<- opcode: QUERY\s|QUERY, status: NOERROR, .*/) { $error = 1; next; } next unless /$fqdn\.\s+(\w+)(\s+A|\s+IN\sA)\s+(.*)/; $error_a = 1; my $time = lc($1); my $ip = $3; my $seconds = $time =~ /[dhms]/ ? string_to_time($time) : $time; my $extended_time = time_to_string($seconds); print "Request: $fqdn\tTTL: $extended_time\tIP: $ip\n" if $verbose; push @data_out, "$ldns\t$fqdn\t$seconds\t$ip\n" if $outfile; } close DIG; if (!$error) { print "Request: $fqdn\tERROR (No domain found)\n" if $verbose; push @data_out, "$ldns\t$fqdn\tERROR\tNO DOMAIN\n" if $outfile; } elsif (!$error_a) { print "Request: $fqdn\tERROR (Domain found, no A record found)\n" if $verbose; push @data_out, "$ldns\t$fqdn\tERROR\tNOT A RECORD\n" if $outfile; } } #### if (@data_out) { open (DATAOUT, ">> $outfile") || die "can't open $outfile: $!"; print DATAOUT @data_out; close DATAOUT; } #### foreach $thing (@ns){ push (@provide, "Unknown"); } #### if ( $help || !@ns && !$nsfile || !@addr && !$addrfile || !$verbose && !$outfile ) { print <