Copyright © tutorialspoint.com

# PERL gethostbyname Function

## Syntax

gethostbyname NAME

## 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 address.

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

## Example

Try following example:

    #!/usr/bin/perl
    use Socket;

        ($name, $aliases, $addrtype,
              $length, @addrs) = gethostbyname "amrood.com";
        print "Host name is $name\n";
        print "Aliases is $aliases\n";

Copyright © tutorialspoint.com