my $res = Net::DNS::Resolver->new; foreach $urls (@hrefs) { my $query = $res->query($urls, "A"); #### #!/usr/bin/perl use LWP::Simple; use Array::Unique; tie @hrefs, 'Array::Unique'; tie @ips, 'Array::Unique'; use Net::DNS; # Store the output of the web page (html and all) in the $content variable # print "URL to Parse? "; $a = ; chop $a; $b = "http://"; $c = $b . $a; $" = \n; my $content = get("$c"); if (defined $content) { #$content will contain the html associated with the url mentioned above. #print $content.""; } else { #If an error occurs then $content will not be defined. print "Error: Get failed"; } # # Parse ALL URLs from the .html page and store all unique entries in the @hrefs array # $content =~ s/\'//g; $content =~ s/\+//g; @hrefs = ($content =~ m/:\/\/\"*([\w\-]+\.[\w\-\.]+?)[\"|\/|\s+]/ig); # # Resolve the URLs stored in the array # my $res = Net::DNS::Resolver->new; foreach $urls (@hrefs) { # ## things are unique here!! # my $query = $res->query($urls, "A"); # ## things are unique here!! # if ($query) { foreach $rr (grep { $_->type eq 'A' } $query->answer) { # ## At this location uniqueness is not preserved # # print ($rr->address . ' '); # This prints out many duplicate IP addresses in a scalar variable # # This was one of my attempts to get things working # This is the closest to what I want to do but the list is not unique. # @ips = ($rr->address); foreach $uips (@ips) { print $uips . "\n"; } } } else { warn "query failed: ", $res->errorstring, "\n"; } } # # for troubleshooting - this print statement is unique # #print $urls . "\n"; # ## More testing below - didn't work # # # Add unique IPs to array @ips # #foreach $unique (@ips) { # print "@ips"; # print $unique . "\n"; #}