well, if you just need IP addresses, this works on Win32 and Linux and doesn't require any external module:
my @ip = ();
my($name,$aliases,$addrtype,$length,@addrs) = gethostbyname('localhost
+');
# @addrs should contain the loopback - 127.0.0.1
# you can skip it if you want
foreach my $addr (@addrs) {
push(@ip, join('.', unpack('C4', $addr)));
}
($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($name);
# @addrs contains our public IP address(es)
foreach my $addr (@addrs) {
push(@ip, join('.', unpack('C4', $addr)));
}
foreach my $ip (@ip) {
print $ip, "\n";
}