-   Programming (
-   -   Ping Multiple Machines in Perl (

JohnMayden 02-21-2012 11:47 PM

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 03:12 AM

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

Cedrik 02-22-2012 05: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 05:56 PM.