编辑代码

use Socket;
use Net::hostent;

print inet_ntoa(gethost("www.sohu.com")->addr);  # prints 208.201.239.50
print "\n"; 
printf "%vd", gethost("www.baidu.com")->addr;     # same thing
print "\n"; 
print gethost("127.0.0.1")->name;                # prints localhost
print "\n"; 
use Net::hostent ':FIELDS';
if (gethost($name_or_number)) {
	print "\n"; 
	print "\n"; 
	print gethost($name_or_number);
	print "\n"; 
	print "\n"; 
	
	print "*$name_or_number*\n";
    print "name is $h_name\n";
    print "aliases are $h_aliases\n";
    print "addrs are ",
        join ", " => map { inet_ntoa($_) } @h_addr_list;
}