Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^7: uninitialized values

by Random_Walk (Parson)
on Aug 20, 2013 at 09:44 UTC ( #1050168=note: print w/ replies, xml ) Need Help??


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.

Pereant, qui ante nos nostra dixerunt!


Comment on Re^7: uninitialized values
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-12-19 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (75 votes), past polls