Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!mephisto!psuvax1!news From: schwartz@groucho.cs.psu.edu (Scott Schwartz) Newsgroups: comp.lang.perl Subject: Re: DNS lookup within perl Message-ID: Date: 2 Aug 90 22:55:11 GMT References: <1593@kuling.UUCP> <7028@umd5.umd.edu> Sender: news@cs.psu.edu (Usenet) Organization: Pennsylvania State University, computer science Lines: 21 In-Reply-To: sherk@umd5.umd.edu's message of 2 Aug 90 21:09:26 GMT Nntp-Posting-Host: groucho.cs.psu.edu In article <7028@umd5.umd.edu> sherk@umd5.umd.edu (Erik Sherk) writes: I need to find the name of a host from within a perl script. The following seems to work, but there must be a better way! Try this: #!/usr/bin/perl @inaddr = (130, 203, 2, 4); if (($name) = gethostbyaddr(pack("C4", @inaddr), &AF_INET)) { print $name, "\n"; } else { print "Unknown address\n"; } sub AF_INET {2;}