in reply to Problems with Ping

Here's a simple example of using Net::Ping, perhaps it will help you find your problem.

#!/usr/bin/perl -w use strict; use Net::Ping; my $host = shift or die "No host specified.\n"; my $p = Net::Ping->new; my $res = $p->ping($host); die "Unknown host $host\n" unless defined $res; print "$host is ", $res ? 'alive' : 'dead', "\n";
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: Problems with Ping
by magnus (Pilgrim) on Feb 07, 2001 at 16:49 UTC
    i have run this program exactly as you've typed it...

    i get the same error:

     Can't locate object method "new" via package "Net::Ping" at ...

    could there be something wrong with the module?

    magnus here is the exact code block:
    (imagine, if you will, Net::Ping has already been called)

    sub reachable { (@machines_to_ping) = @_; $host = Net::Ping->new(); foreach (@machines_to_ping){ $reachable = $host->ping($_); if ($reach == 1){ print "$_ reachable\n"; } else { print "$_ not reachable\n"; } } }
    hopefully this helps...