use strict; use warnings; use Nmap::Scanner; my @systems = qw(localhost other); my $scanner = new Nmap::Scanner; $scanner->tcp_syn_scan; $scanner->add_scan_port('22'); $scanner->add_scan_port('80-82'); for (@systems){ $scanner->add_target($_); } my $results = $scanner->scan; my $hosts = $results->get_host_list; while (my $host = $hosts->get_next) { print "\nOn " . $host->hostname . ": \n"; my $ports = $host->get_port_list; while (my $port = $ports->get_next) { print join(' ', 'Port', $port->portid, 'is in state', $port->state, "\n" ); } } __END__ On localhost: Port 22 is in state open Port 80 is in state closed Port 81 is in state closed Port 82 is in state closed On other: Port 22 is in state closed Port 80 is in state closed Port 81 is in state closed Port 82 is in state closed