programming-examples/perl/Network/The gethostaddr function translates a network address to its corresponding names.pl
2019-11-15 12:59:38 +01:00

7 lines
289 B
Perl

Format: gethostbyaddr(ADDRESS, DOMAIN_NUMBER);
#!/bin/perl
$address=pack("C4", 127,0,0,1);
($name, $aliases, $addrtype, $length, @addrs) = gethostbyaddr($address,2);
($a, $b, $c, $d) = unpack ( 'C4', $addrs[0]);
print "Hostname Is $name and the Internet address Is $a.$b.$c.$d.\n";