... # $addr is the actual subnet, e.g. "192.168.1.0" ... my $output = qx{nmap -sP ${addr}/24}; my @nodes= $output =~ /(?<=\s)c\w+\b/g;