foreach my $ip (@IPsinrange) { for my $host_obj ($np->all_hosts()) { if ($host_obj->ipv4_addr() eq $ip) { foreach my $port (@ports) {