當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Perl endhostent用法及代碼示例



描述

此函數告訴係統您不再期望使用 gethostent 從主機文件中讀取條目。

用法

以下是此函數的簡單語法 âˆ'

endhostent

返回值

此函數不返回任何值。

示例

以下是顯示其基本用法的示例代碼 -

#!/usr/bin/perl

while( ($name, $aliases, $addrtype, $length, @addrs) = gethostent() ) {
   print "Name  = $name\n";
   print "Aliases  = $aliases\n";
   print "Addr Type  = $addrtype\n";
   print "Length  = $length\n";
   print "Addrs  = @addrs\n";
}

sethostent(1);

while( ($name, $aliases, $addrtype, $length, @addrs) = gethostent() ) {
   print "Name  = $name\n";
   print "Aliases  = $aliases\n";
   print "Addr Type  = $addrtype\n";
   print "Length  = $length\n";
   print "Addrs  = @addrs\n";
}

endhostent();  # Closes the database;

當上麵的代碼被執行時,它會產生下麵的結果——

Name  = ip-50-62-147-141.ip.secureserver.net
Aliases  = ip-50-62-147-141 localhost.secureserver.net localhost.localdomain localhost
Addr Type  = 2
Length  = 4
Addrs  = 
Name  = ip-50-62-147-141.ip.secureserver.net
Aliases  = ip-50-62-147-141 localhost.secureserver.net localhost.localdomain localhost
Addr Type  = 2
Length  = 4
Addrs  = 

相關用法


注:本文由純淨天空篩選整理自 Perl endhostent Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。