use strict; use warnings; use Net::Ping; my $p = Net::Ping->new('tcp'); $p->tcp_service_check(1); my $host = "192.168.100.12"; my $port = 80; $p->{'port_num'} = $port; print "The service on $host port $port is ", ($p->ping($host) ? "up" : "down"), ".\n";