Perl getnetbyname Function

Advertisements


Description

This function returns the information for the network specified by NAME(in list context) ($name, $aliases, $addrtype, $net)

Syntax

Following is the simple syntax for this function:

getnetbyname NAME

Return Value

This function returns undef on error otherwise Network address in scalar context and empty list on error otherwise Network record (name, aliases, address type, network address) in list context.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl

use Socket;

($name, $aliases, $addrtype, $net)  = getnetbyname("loopback");

print "Name = $name\n";
print "Aliases = $aliases\n";
print "Addrtype = $addrtype\n";
print "Net = $net\n";

When above code is executed, it produced following result

Name = loopback
Aliases = 
Addrtype = 2
Net = 2130706432


Advertisements
Advertisements