Listing 12. ping.pl

#!/usr/bin/perl
# ping.pl - a program to ping a host
use Net::Ping;
$pinghost = 'server.onsight.com';
$p = Net::Ping->new("tcp", 2);
for (;;) {
   unless ($p->ping($pinghost)) {
         print "Fail: ", scalar(localtime), "\n";
   } else {
      print "Success: ", scalar(localtime), "\n";
   }
        sleep 10;
}