use strict; use warnings; my $opsys = $^O; print "Hello, your operating system is: $opsys" . "\n"; if ($opsys =~ /linux/) { my $nics = qx |/sbin/ifconfig| or die("Can't get info from ifconfig: $!\n"); my @nics = split /(?<=\n)(?=\w)/, $nics; for (@nics){ my ($interface) = /^eth(\d)/ or next; my ($ip) = /\binet addr:([\d.]+)/ or next; print "Interface $interface has the IP Address of $ip\n"; } } else { my $nics = qx |ifconfig -a| or die("Can't get info from ifconfig: $!\n"); my @nics = split /(?<=\n)(?=\w)/, $nics; for (@nics){ my ($interface) = /^fjgi(\d)/ or next; my (@ip) = /\binet ([\d.]+)\snetmask ([\d]+)\sbroadcast ([\d.]+)/ or next; print "Interface $interface has the IP Address of $ip[0]\n \tNetmask: $ip[1]\n \tBroadcast $ip[2]\n"; } } #### my ($ip, $mask, $bcast) = /\binet ([\d.]+)\snetmask ([\d]+)\sbroadcast ([\d.]+)/ or next; print "Interface $interface has the IP Address of $ip\n \tNetmask: $mask\n \tBroadcast $bcast\n";