你的分享就是我们的动力 ---﹥

Perl 的 gethostbyname 使用方法

时间:2013-05-30 00:10来源:www.chengxuyuans.com 点击:

代码简介

暂无

Perl代码片段

# The syntax is (name, altnames, addrtype, len, addrs) = gethostbyname (inname); 


#!/usr/local/bin/perl 

$machine ="123.1.1.1"; 
if (!(($name, $altnames, $addrtype, $len, @addrlist) = gethostbyname ($machine))) { 
    die ("Machine name $machine not found.\n"); 
} 
print ("Equivalent addresses:\n"); 
for ($i = 0; $i < @addrlist; $i++) { 
    @addrbytes = unpack("C4", $addrlist[$i]); 
    $realaddr = join (".", @addrbytes); 
    print ("\t$realaddr\n"); 
} 

转载注明地址:http://www.chengxuyuans.com/Perl/63123.html