NAME
Mock::Net::Ping - Mock Net::Ping's ping method
SYNOPSIS
use Net::Ping;
require Mock::Net::Ping;
my $p = Net::Ping->new();
my $host = '127.0.0.1';
my ( $ok, $elapsed ) = $p->ping( $host );
printf "%s is %s reachable\n", $host, $ok ? '' : 'NOT';
$host = '8.8.8.8';
my ( $ok, $elapsed ) = $p->ping( $host );
printf "%s is %s reachable\n", $host, $ok ? '' : 'NOT';
DESCRIPTION
This module mocks Net::Ping by overriding the methods. Currently ping is the only method supported.
Functions
- $p->ping($host [, $timeout]);
-
Pretend to ping the remote host and wait for a response. $host can be either the hostname or the IP number of the remote host. The optional timeout must be greater than 0 seconds and defaults to whatever was specified when the ping object was created. Returns a success flag. If the host is localhost, any address in 127.0.0.0/8 or any private IP address, the success flag will be 1. For all other hosts, the success flag willbe 0. In array context, the elapsed time as well as the host that was passed (except localhost will be converted to 127.0.0.1). The elapsed time value will be a float, as returned by the Time::HiRes::time() function.
ACKNOWLEDGEMENTS
This module would not exist without Net::Ping and this documentation is based heavily on that.
AUTHOR
Matthew Musgrove <mr.muskrat@gmail.com>
COPYRIGHT
Copyright (c) 2014, Matthew Musgrove. All rights reserved.
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.