http://www.perlmonks.org?node_id=1072651

Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys,

I have an active wireless connection on my Linux box (Kubuntu 13.10). When I manually ping Google with ping www.google.com at the command prompt I get the following output:

PING www.google.com (173.194.34.144) 56(84) bytes of data. 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=1 t +tl=57 time=159 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=2 t +tl=57 time=190 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=3 t +tl=57 time=72.6 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=4 t +tl=57 time=199 ms 64 bytes from lhr14s21-in-f16.1e100.net (173.194.34.144): icmp_seq=5 t +tl=57 time=69.4 ms

But when I use Net::Ping in a perl script like this:

my $p = Net::Ping->new("tcp", 2); # With or without this next line. $p->port_number(getservbyname("http", "tcp")); if ($p->ping("www.google.com")) { print "Host is reachable\n"; return 1; } else { print "Host is not reachable\n"; return 0; }

I get "Host is not reachable" rather than the "Host is reachable" suggested by running ping manually.

What is happening here?

Thanks very much.

Steve.