$args = "nmap -sS -iL ips.txt -p 1-1024 172.27.1.4"; @list = split(/\ /, $args); foreach $list (@servicelist) { if ($list =~/-p/) { ......