The getnetent function steps through the file /etc/networks, which lists the names and addresses of the networks your machine is on. : getnetent « Network « Perl






The getnetent function steps through the file /etc/networks, which lists the names and addresses of the networks your machine is on.

   

# The syntax is (name, altnames, addrtype, net) = getnetent(); 

#!/usr/local/bin/perl 

while (($name, $altnames, $addrtype, $rawaddr) = getnetent()) { 
    @addrbytes = unpack ("C4", $rawaddr); 
    $address = join (".", @addrbytes); 
    print ("$name, at address $address\n"); 
} 

   
    
    
  








Related examples in the same category