setservent STAYOPEN |
getservent()檢索的信息服務數據庫中的下一行,然後setservent集(或重置)枚舉的主機項的設置開始。該功能應該是在第一次調用前調用getservent。STAYOPEN參數是可選的,在大多數係統上未使用過。
Nothing
試試下麵的例子:
#!/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 /etc/services; #by www.gitbook.net/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"; } endservent(); # Closes the database;