For whatever reason, this problem keeps cropping up, so I'm hoping someone can shed some light on the problem so I can eliminate it once and for all.
This code works:
This code does not:while (<>) { if (!/^#+/) { ($source, $destination, $bytes) = split; $net_activity{$source}{$destination} += $bytes; }# ignore comments }# read in each line of the net log
I get lots of these:my($one_line) = ''; while ($one_line = <>) { if ($one_line =~ !/^#+/) { ($source, $destination, $bytes) = split(/ /, $one_line); $net_activity{$source}{$destination} += $bytes; }# ignore comments }# read in each line of the net log
The program still WORKS (i.e. does what it's supposed to do), but it throws up all those warnings first.Use of uninitialized value in pattern match (m//) at ./net_traffic2 li +ne 14, <> line 5.
I know I'm doing something Very Dumb(TM) here, but if someone could point it out I'd be extremely grateful. I want to understand this whole "unitialized variable" thing because it keeps coming up even when I think I've initialized the variable. Apparently Perl and I have different ideas of what that means, so I want to get in line.
Many thanks!
C_T
In reply to Help with recurring "uninitialized variable" problem. by C_T
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |