Perl Ping Example Code

IT Support Forum Forums Development Perl Perl Ping Example Code


Viewing 0 reply threads
  • Author
    • #1968

      There are two ping commands available in Perl that I know of. I’ll share these below with a few examples…

      The first is Net::Ping. It’s not very reliable in my experience as it doesn’t work with all IP addresses very well. I know not why. Here’s an example of Net::Ping:

      use Net::Ping;
      my $p = Net::Ping->new();
      if ($p->ping(“”))
      print “ok\n”;
      print “fail\n”

      The next ping is System Ping. Here’s an example of the code to do a System Ping in Perl:

      if ($retval==0)
      print “OK\n”;
      } else {
      print “FAIL\n”;

Viewing 0 reply threads
  • You must be logged in to reply to this topic.