當前位置:首頁 » Perl » perl setservent()函數

perl setservent()函數

perl setservent()函數例子,setservent()函數實例代碼

語法

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;