当前位置: 首页 > 文档资料 > Perl 入门教程 >

endnetent

优质
小牛编辑
149浏览
2023-12-01

描述 (Description)

此函数告诉系统您不再期望使用getnetent从网络列表中读取条目。

语法 (Syntax)

以下是此函数的简单语法 -

endnetent

返回值 (Return Value)

此函数不返回任何值。

例子 (Example)

以下是显示其基本用法的示例代码 -

#!/usr/bin/perl
use Socket;
while ( ($name, $aliases, $addrtype, $net)  = getnetent() ) {
   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Addrtype = $addrtype\n";
   print "Net = $net\n";
}
setnetent(1); # Rewind the database;
while ( ($name, $aliases, $addrtype, $net)  = getnetent() ) {
   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Addrtype = $addrtype\n";
   print "Net = $net\n";
}
endnetent();  # Closes the database;

执行上述代码时,会产生以下结果 -

Name = default
Aliases = 
Addrtype = 2
Net = 0
Name = loopback
Aliases = 
Addrtype = 2
Net = 2130706432
Name = link-local
Aliases = 
Addrtype = 2
Net = 2851995648
Name = default
Aliases = 
Addrtype = 2
Net = 0
Name = loopback
Aliases = 
Addrtype = 2
Net = 2130706432
Name = link-local
Aliases = 
Addrtype = 2
Net = 2851995648