Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-21-2012, 11:47 PM   #1
LQ Newbie
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
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

Old 02-22-2012, 03:12 AM   #2
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,548

Rep: Reputation: 136Reputation: 136
i can ping them with your second script. I've changed 'icmp' to 'syn'
Old 02-22-2012, 05:09 AM   #3
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Try using different variable names...

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Canīt ping machines with dynamic IPīs Wurzelseppi Linux - Networking 8 05-19-2009 02:16 AM
How come I can ping between machines, but not get internet? ozymandias Linux - Networking 5 09-11-2005 04:20 PM
machines with different submasks can ping each other, why? learnfast Linux - Newbie 1 03-11-2005 09:11 AM
Cannot ping between 2 machines on same router acampbell Linux - Wireless Networking 8 02-24-2004 03:27 AM
Ping between machines triplem Linux - Networking 1 04-14-2003 05:17 PM

All times are GMT -5. The time now is 02:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration