in reply to Re^6: uninitialized values
in thread uninitialized values
You really need to use some helpful names for your variables. I started to work on your code and gave up because while I have a good idea what this means:
print "$hostname\n"; print "$ip\n"; print "$pkt_size\n"; print "$ttl\n";
it will take me some time to work out what this means:
#print "$values1[1] \n"; # print "$val1[0] \n"; #print "$val1[1] \n"; #print "$val2[1] \n";
I would suggest, other than using sane variable names, that you alter your series of if statements to use the if/elsif/else construct. This will give you a way to catch the error conditions from your ping.
On a more minor point, it looks like you only allow a restricted range of IP addresses for your $host value. Yet later you capture the IP used by ping. Is there a case where you ask it to ping n.n.n.n and it pings m.m.m.m? If not you can just use the IP you fed into it.
Cheers,
R.
|
|---|