use strict; use Socket; my $p = gethostbyname('localhost'); my $ip = inet_ntoa($p); print "$ip\n"; #### perl -MSocket -le 'print scalar gethostbyaddr(inet_aton("127.0.0.1"),AF_INET)'