use CGI qw(:standard); # you already have this
use CGI::Carp;
use CGI::Carp qw(fatalsToBrowser);
local $SIG{__WARN__} = \&Carp::cluck;
####
use Net::Ping;
my @protocols = qw(icmp tcp);
my @host_array = ("www.google.com",
"irc.webchat.org",
"64.177.244.76");
foreach my $proto (@protocols) {
my $p = Net::Ping->new($proto);
foreach my $host (@host_array) {
print "With $proto, $host does ";
print "NOT " unless $p->ping($host);
print "respond\n";
}
$p->close();
}
####
With icmp, www.google.com does respond
With icmp, irc.webchat.org does respond
With icmp, 64.177.244.76 does respond
With tcp, www.google.com does NOT respond
With tcp, irc.webchat.org does NOT respond
With tcp, 64.177.244.76 does NOT respond