示例
以下是显示其基本用法的示例代码-
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