Mega Code Archive

 
Categories / Perl / Network
 

The getnetent function steps through the file etcnetworks, 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");  }