The gethostent function returns a list consisting of the next line from the /etc/hosts file. : gethostent « Network « Perl






The gethostent function returns a list consisting of the next line from the /etc/hosts 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";
}

   
    
    
  








Related examples in the same category