Perl nslookup
From DWIKI
<enscript lang=perl> sub nslookup {
my $name = shift; if( ! $name ) { print STDERR "nslookup: no argument given\n"; return undef; } my @addresses; eval { @addresses = gethostbyname($name) }; if( $@ ) { print STDERR "nslookup: failed to resolve $name -> $!\n"; return undef; } @addresses = map { inet_ntoa($_) } @addresses[4 .. $#addresses]; return $addresses[0];
} </enscript>