If this is the case, you need to add one more loop :
By the way, your %AoH is really a HASH whose VALUES are Array-refs, and would probably be better named as "HoA".for my $key (keys %AoH) { for my $domain qw(ns7.xxx.com wrnadc02.xx.xxxxxx.com) { nsqry($domain, $_ ) for @{$AoH{$key}} ; } }
I imagine (Having written similar functionality myself), that you may eventually want to associate the domain name with the IP-address when you find it. Your current data structure will make that association very complicated. Here is my suggested structure/code:
my @domain = ( {NAME => 'ns7.xxx.com', IPLIST => []} # IP +LIST gets populated dynamically, as discovered , {NAME => 'wrnadc02.xx.xxxxxx.com', IPLIST => []} ); my %IPinfo; # This will be a HoH for (qw (10.220.84.30 10.220.84.51 10.220.84.52 10.220.84.54 ...){ $IPinfo{$_}= {DOMAININDEX => undef, TYPE => "CLIENT"}; } .... OUTER: for my $ip (keys %IPinfo){ for my $domidx (0..$#domain){ my $ptr = nsquery($domain[$domidx]->{NAME}, $ip) ; # Assumi +ng "nsquery" has been modified to return the info next unless $ptr; # No change, if $ptr is empty $IPinfo{$ip}{DOMAININDEX} = $domidx; # Forward ref from IP +to DOMAIN $IPinfo{$ip}{PTR} = $ptr; push @{$domain[$domidx]->{IPLIST}}, $ip; # Keep a list of I +P's that live in this domain next OUTER; # we bail after the first domain found (More ef +ficient) } }
"As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom
In reply to Re: loop ending b4 I want it to
by NetWallah
in thread loop ending b4 I want it to
by mikejones
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |