Sys::Net - system network information or actions
my %if_named = %{Sys::Net::interfaces()}; foreach my $if_name (keys %if_named) { print 'interface with name: ', $if_name, ' has ip: ', $if_named{$if_name}, "\n"; } use Sys::Net 'resolv'; my $hostname = resolv('127.0.0.1'); my $ip = resolv('localhost');
The purpouse is to find out network information or perform system network actions.
System network interfaces for the moment works just for Linux, and gets only ipv4 ip of the system interfaces. Will be extended when a need arrise.
our @EXPORT_OK = qw(resolv interfaces);
returns hash ref with:
{ 'lo' => { 'ip' => '127.0.0.1' }, 'eth0' => { 'ip' => '192.168.100.6' }, };
TODO more information than just an ip.
Resolv hostname to an ip or ip to an hostname.
Using gethostbyaddr or gethostbyname so also hosts in /etc/hosts are taken into an account.
Jozef Kutej
To install Test::Server, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Server
CPAN shell
perl -MCPAN -e shell install Test::Server
For more information on module installation, please visit the detailed CPAN module installation guide.