Use of uninitialized value $val in concatenation (.) or string at ./ping_linux.pl line 69, <CMD> line 2.

Your warning message is about an unitialized $val variable, but you are not using any such variable in the code you have posted (you're declaring one, but not using it).

The waning message also mentions line 69 of your code, the code you display is about 15 lines. How do you expect us to tell you what is wrong in line 69 if you don't show it to us?

Please give us line 69 of your code, or give us a correct warning message. You need to be very accurate on these types of things if you want us to be able to help. Please help us to help you.

In addition to other problems indicated by others (and using meaningful variable names is really not a luxury, we could understand much better what you are trying to do if your variables names would tell us what they are intended to contain; to me using meaningful names for variables, subroutines, etc. is the most important form of code comment), I also doubt quite a bit that the following lines (at least the two last ones) do what you want:

@values1 = split ; @val1 = split(/\(/,$values1[3]); $val1[1] =~ s/\)//;

Please supply a sample of the ping command output, so that we can figure out what these code lines are supposed to do. Also you don't use $val1[1] after having assigned it, what's the point?

BTW, the fact that you have this warning on line 2 possibly simply means that the second line of your input is empty.


In reply to Re: uninitialized values by Laurent_R
in thread uninitialized values by gaurav

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.