setprotoent STAYOPEN |
為得到protoent()檢索信息的協議數據庫中的下一行,然後setprotoent集(或重置)枚舉的主機項的設置開始。這個函數應該被調用之前在第一次調用getprotoent。STAYOPEN參數是可選的,在大多數係統上未使用過的。
Nothing
試試下麵的例子:
#!/usr/bin/perl
#by www.gitbook.net
while(($name, $aliases, $protocol_number) = getprotoent()){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Protocol Number = $protocol_number\n";
}
setprotoent(1); # Rewind the database.
while(($name, $aliases, $protocol_number) = getprotoent()){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Protocol Number = $protocol_number\n";
}
endprotoent(); # Closes the database