Perl : code on ping showing difference result

Hi all,

I am using the below code to ping a code and print whehter the connection is successful or not.

    use Net::Ping;
    $p = Net::Ping->new();    
    my $host = "x.x.x.x";
   # print "$host is alive.\n" if $p->ping($host);
    if ($p->ping($host,3))
    {
        print "success";
    }
    else
    {
         print "Fail";
    }     
    $p->close();

For one IP address.. I received the status as "Fail" . But when tried using start->run-> cmd ->ping ipaddress .. the ping is successful.

COuld you let me know any other alternative code to ping the device.

---------- Post updated at 06:57 AM ---------- Previous update was at 06:50 AM ----------

Hi all,

I am using the below code to ping a code and print whehter the connection is successful or not.

    use Net::Ping;
    $p = Net::Ping->new();    
    my $host = "x.x.x.x";
   # print "$host is alive.\n" if $p->ping($host);
    if ($p->ping($host,3))
    {
        print "success";
    }
    else
    {
         print "Fail";
    }     
    $p->close();

For one IP address.. I received the status as "Fail" . But when tried using start->run-> cmd ->ping ipaddress .. the ping is successful.

COuld you let me know any other alternative code to ping the device.