Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello

is there a way that lets me find out the ips bound to the server

or I'll have to go through ifconfig & parse the output to get a list of ips ?

I'll need to get IPv4 addresses only.

Replies are listed 'Best First'.
Re: IPS bound to server
by Khen1950fx (Canon) on Dec 15, 2009 at 07:13 UTC
    You could use Sys::HostIP:

    #!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; use Sys::HostIP; my $ip_address = Sys::HostIP->ip; my $ip_addresses = Sys::HostIP->ips; my $interfaces = Sys::HostIP->interfaces; print Dumper($ip_address, $ip_addresses, $interfaces, "\n");

      Thanks

      As I can see all it does is parsing the output of "ifconfig" as I had in mind.

      Seems to be no other solutions are available.