Mega Code Archive

 
Categories / Perl / Network
 

The gethostent function returns a list consisting of the next line from the etchosts file

#!/bin/perl while ( ($name,  $aliases, $addrtype, $length, @addrs) =gethostent ){     ($a, $b, $c, $d) = unpack ( 'C4', $addrs[0]);     print "The name of the host is $name.\n";     print "Local host address (unpacked) $a.$b.$c.$d\n"; }