Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL gethostbyaddr Function



Syntax

gethostbyaddr ADDR, ADDRTYPE


Definition and Usage

Contacts the system's name-resolving service, returning a list of information for the host ADDR of type ADDRTYPE, as follows:

($name, $aliases, $addrtype, $length, @addrs)

The @addrs array contains a list of packed binary addresses. In a scalar context, returns the host address

Return Value

  • In scalr context undef on error and otherwise host name.

  • In list context Empty list on error otherwise host record shown above.

Example

Try following example:

#!/usr/bin/perl
use Socket;

    $iaddr = inet_aton("127.1"); # or whatever address
    $name  = gethostbyaddr($iaddr, AF_INET);
    print "Host name is $name\n";



Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names