-   Programming (
-   -   Ping Multiple Machines in Perl (

JohnMayden 02-22-2012 12:47 AM

Ping Multiple Machines in Perl
Evening Gents!
Im having a little trouble with a perl script to ping multiple machines. I can ping one easily enough with

use Net::Ping;

my $ip = '724.125.237.50';
my $ping = Net::Ping->new( "icmp", 1, 64);
if ( $ping->ping($ip) ) {
print "$ip answered\n";
else {
print "$ip did not answer\n";

But i cant seem to ping multiple machines, i've tried something like.

use Net::Ping;

my @ip = qw(;
my $ping = Net::Ping->new("icmp", 5);

foreach $ip (@ip){
print "$ip answered\n";

But obviously this isnt working!
Any help would be great peeps


j-ray 02-22-2012 04:12 AM

i can ping them with your second script. I've changed 'icmp' to 'syn'

Cedrik 02-22-2012 06:09 AM

Try using different variable names...

I mean for ips list, use @ips and $ip for each ip

All times are GMT -5. The time now is 11:38 AM.