Welcome to the most active Linux Forum on the web.
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-22-2012, 12:47 AM   #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, 04:12 AM   #2
Senior Member
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,551

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

Rep: Reputation: 243Reputation: 243Reputation: 243
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 03:16 AM
How come I can ping between machines, but not get internet? ozymandias Linux - Networking 5 09-11-2005 05:20 PM
machines with different submasks can ping each other, why? learnfast Linux - Newbie 1 03-11-2005 10:11 AM
Cannot ping between 2 machines on same router acampbell Linux - Wireless Networking 8 02-24-2004 04:27 AM
Ping between machines triplem Linux - Networking 1 04-14-2003 06:17 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:23 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