in reply to extract uniques and sort
If you're worried about catching duplicate *hostnames* (e.g. "host" v. "host.example.com" could be the same hostname if your domain is example.com), you'll have to try resolving each name individually, and perhaps storing the resulting IP address in the hash instead:
Note that $ip is in packed form here.use Socket; while (my $item = <FILE>) { if (my $ip = gethostbyname($item)) { $hash{$ip} = gethostbyaddr($ip, AF_INET) || $item; } else { # no such hostname } } print "Unique items:\n"; print "$hash{$_}\n" for keys %hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: extract uniques and sort
by geektron (Curate) on Sep 21, 2000 at 04:55 UTC | |
by Fastolfe (Vicar) on Sep 21, 2000 at 17:32 UTC | |
by geektron (Curate) on Sep 23, 2000 at 05:05 UTC | |
|
RE: (2) extract uniques and sort (thanks, getting closer))
by ybiC (Prior) on Sep 21, 2000 at 19:33 UTC | |
by Fastolfe (Vicar) on Sep 21, 2000 at 19:48 UTC |