Your arrays @values2 and @val2 and the scalar $val are never used, so let's remove them for now.
The main problem is that your assignment to zero is almost certainly not doing what you want. It is setting @values1 to (0) and @val1 to undef. When the "if" expression is false, those values are not changed and so what you are attempting to print is undefined - hence the warning. To illustrate, try changing your loop like this:
while (<CMD>) { my (@values1) = ('Not set', 'Really not set'); my (@val1) = ('Nothing here', 'Nor here'); # Nothing changed below here if ( $_ =~ /PING/ ){ @values1 = split ; @val1 = split(/\(/,$values1[3]); $val1[1] =~ s/\)//; } print "$values1[1] \n"; print "$val1[0] \n"; }
I would also very strongly urge you to get into the habit of choosing meaningful names for your variables. @values1, @val1, @values2, @val2 and $val are all very similar and equally meaningless and this really adds to the confusion of the code.
Good luck.
In reply to Re: uninitialized values
by hippo
in thread uninitialized values
by gaurav
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |