use Net::Ping; my $p; $p = Net::Ping->new('tcp',1); my $port = '3000'; $p->port_number($port); my $timeout = 10; my @ip = ('192.168.0.1','127.0.0.1','19.208.226.252','46.9.118.111','57.88.211.216','99.142.126.191','57.226.26.163','205.48.22.171','225.235.31.150','232.169.84.210', '93.239.247.55','151.242.150.119','15.74.220.132','58.230.90.160','219.186.233.148', '192.188.162.6','127.0.0.1'); foreach (@ip){ if ($p->ping("$_")){ print "$_ is alive.\n" } else{ print "$_ is not alive \n"; } }