Perl Ping Example Code

IT Support Forum Forums Development Perl Perl Ping Example Code


This topic contains 0 replies, has 1 voice, and was last updated by  Webmaster 2 years, 11 months ago.

  • 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”;

You must be logged in to reply to this topic.