use Cmd; use P; use Cmds qw(ip); # command finder that produces '$Ip' with abspath of 'ip' my @cmd = qw( $Ip addr list ); local $_; my %intf2addrs; my $intf; while ($_=Cmd->run(\@cmd)) { if (/^(\S+):/) { $intf=$1;next; } if (/^\s+inet\s([^\s]+)\s/) { next unless $intf; $int2addrs{$intf}=$1; P "intf %10s: %s", $intf, $1; } } ...