endservent
优质
小牛编辑
137浏览
2023-12-01
描述 (Description)
此函数告诉系统您不再期望使用getservent从services文件中读取条目。
语法 (Syntax)
以下是此函数的简单语法 -
endservent
返回值 (Return Value)
此函数不返回任何值。
例子 (Example)
以下是显示其基本用法的示例代码 -
#!/usr/bin/perl
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;
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;
<!--When above code is executed, it produces the following result −
-->