#In this perl code, im getting the input as "ip address" from the user and pinging it
#To check the servers can able to ping or not
#!/usr/bin/perl
use Net::Ping;
$p=Net::Ping->new();
print " ENTER THE NUMBER OF SERVERS \n";
my $servers=<STDIN>;
for($i=1; $i<=$servers; $i++)
{
print "ENTER THE SERVER $i IP ADDRESS \n";
$i[a]=<STDIN>;
}
for($i=1; $i<=$servers; $i++)
{
if($i[a]=~ /\d+.\d+.\d+.\d+/)
{
if($p->ping("$i[a]"))
{
print "\n PING IS SUCESSSSSS!!!! \n";
print "$i[a] \n";
}
else
{
print "\n \a REQ TIMED OUT \n";
print "$i[a] \n";
}
}
}
#In this perl code, im getting the input as "ip address" from the user and pinging it. when i compile and run this code, say when i get 3 ipaddress from the user only my 3rd ip is pinging, the 1st 2 "ipaddress" are not pinging. So could you please tell me what is the error?
|