示例
以下是显示其基本用法的示例代码-
while(($name, $aliases, $port_number,
$protocol_name) = getservent()) {
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Port Number = $port_number\n";
print "Protocol Name = $protocol_name\n";
}
setservent(); # Rewind the database /etc/services;
while(($name, $aliases, $port_number,
$protocol_name) = getservent()) {
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Port Number = $port_number\n";
print "Protocol Name = $protocol_name\n";
}
endservent(); # Closes the database;