Perl Makes Testing Easy Perl Testing #28

Pinging

use Test::More 'no_plan';
use Net::Ping;
my $p = Net::Ping->new;
$p->hires;
my @hosts = ...
foreach my $host (@hosts) {
    my ($ret, $dur, $ip) = $p->ping($host);
    ok($ret, "pinged $host");
    diag("response time for $host was $dur");
}
Copyright © 2006 Ian Langworth