in reply to uninitialized values
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: uninitialized values
by gaurav (Sexton) on Aug 19, 2013 at 13:40 UTC | |
by AnomalousMonk (Archbishop) on Aug 19, 2013 at 15:19 UTC | |
by gaurav (Sexton) on Aug 19, 2013 at 13:45 UTC |