Try printing the value of '$location' within your loop, and surround it with some sort of visual delimiters. E.g.
while (my ($location, $devices) = each %devicecount) { # Test the above variables print "Loc: [[[$location]]]\tDev: [[[$devices]]]\n"; foreach my $line (@workingdata) { ...
It doesn't seem likely that it's actually undefined, since you can't have an undefined key in a hash. If you show us more of your code - especially a complete but minimal script that can be executed and demonstrates the error - we'd be in a much better position to help you.
Update: You should also make sure that the value of '$location' within the regex is treated as a literal string; this will prevent problems if it happens to contain any regex metacharacters. I.e.,
if (/\Q$location\ETEXT/) {
-- Human history becomes more and more a race between education and catastrophe. -- HG Wells
In reply to Re: uninitialized variable warning
by oko1
in thread uninitialized variable warning
by vatheck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |