yes you are right...I would like to match the domain names with the IP lookup, however I do not want to skip the second lookup if any IP is found in the 1st domain because I want to see if an IP is in both domains. When you said "Assuming "nsqry" has been modified to return the info," I became confused in trying to modify the sub. Will you help?
#!/usr/bin/perl use strict; use warnings; use Carp; use Net::DNS; use Data::Dumper; my @domain = ( { NAME => 'ns7.pyxis.com', IPLIST => [] } , ## Autovivification { NAME => 'wrnadc02.na.alarismed.com', IPLIST => [] } ) ; my %IPinfo; # HoH for my $IP (qw ( 10.220.84.30 10.220.84.51 10.220.84.52 10.220.84.54 10.220.84.55 10.220.84.56 10.220.84.57 10.220.84.58 10.220.84.59 10.220.84.60 10.220.84.61 10.220.84.62 10.220.84.64 10.220.84.65 10.220.84.70 10.220.84.71 10.220.84.72 10.220.84.73 10.220.84.74 )) { $IPinfo{$IP} = {DOMAININDEX => undef, TYPE => "CLIENT" } ; } for my $ip (keys %IPinfo) { for my $domids (0..$#domain) { my $ptr = nsqry($domain[$domids]->{NAME}, $ip) ; next unless $ptr ; # No change, if $ptr is empty $IPinfo{$ip}{DOMAININDEX} = $domids ; $IPinfo{$ip}{PTR} = $ptr ; push @{$domain[$domids]->{IPLIST}}, $ip ; } } sub nsqry { my ( $nssvr, @clients ) = @_ ; my $res = Net::DNS::Resolver->new ( nameservers => [$nssvr], recurse => 1, ## do recursive lookups retry => 1, debug => 0, ) ; for my $client (@clients) { my $query = $res->search($client) ; if ($query) { for my $rr ($query->answer) { next unless ($rr->type eq "PTR"); print $rr->ptrdname, "\n" ; } } else { warn "query failed: ", $res->errorstring, "\n" ; } } } print Dumper(\@domain); $VAR1 = [ { 'NAME' => 'ns7.pyxis.com', 'IPLIST' => [] }, { 'NAME' => 'wrnadc02.na.alarismed.com', 'IPLIST' => [] } ];

In reply to Re^2: loop ending b4 I want it to by mikejones
in thread loop ending b4 I want it to by mikejones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.