http://qs321.pair.com?node_id=311626

sunadmn has asked for the wisdom of the Perl Monks concerning the following question:

Greeting all,
I have this code so far but I am trying to figure out how to sort on the hashes I have built in my sub routine, where I am getting a bit confused is the returned value from my nslookup will not always be in the same order so ip for ns1.t might not be the first, but the second or last. With that said will my sort still work or should I build my hashes as a hash of an array?? This is really confusing to me and I really have no idea where to start. Any help you might offer would be great.

SUNADMN
USE PERL
#!/usr/bin/perl use strict; use Net::Nslookup; my $input = '/var/tmp/clean'; my $ours = '/var/tmp/ours'; my $theirs = '/var/tmp/theirs'; my $unknown = '/var/tmp/unknown'; open(IN, "$input") || die "Can't open $input\nReason: $!\n"; open(OUT, ">$ours") || die "Can't create $ours\nReason: $!\n"; open(OUT1, ">$theirs") || die "Can't create $theirs\nReason: $!\n"; open(OUT2, ">$unknown") || die "Can't create $unknown\nReason: $!\n"; my @ns; while(<IN>) { my $domain = $_; chomp $domain; @ns = nslookup(domain => "$domain", type => "NS"); &ours; # for(@ns) { # print "@ns\n"; # } } sub ours { my %ours ( '24.56.102.10' => ns1.t, '24.56.100.10' => ns2.t, '24.56.100.11' => ns3.t ) my %theirs ( '68.168.192.17' => ns1.a, '24.50.78.2' => ns2.a, '68.168.224.177' => ns3.a ( if($ours{ns1.t}) { print OUT "$_\n"; } elseif($theirs{ns1.a}) { print OUT1 "$_\n"; } } close(IN); close(OUT); close(OUT1); close(OUT2); exit;