my $p = Net::Ping->new("tcp", 2); # With or without this next line. $p->port_number(getservbyname("http", "tcp")); if ($p->ping("www.google.com")) { print "Host is reachable\n"; return 1; } else { print "Host is not reachable\n"; return 0; }