It is in the correct scope the way it is being used (global in this case), it's just difficult to tell because of poor code formatting. It should all be left-justified, with the exception of the statements within the while and unless statements, which should be indented only once.
Perl::Tidy can help those who are unfamiliar with proper indentation get a good grasp of it.
my %CONFIG_PARAMS;
my $mapattach;
while (my ($key , $value) = each(%CONFIG_PARAMS)) {
if ($file =~ /$key/) {
$mapattach = $value;
}
}
unless (defined $mapattach) {
Println "WARN : Ignoring $file, not found in the config file";
}
What I see is that %CONFIG_PARAMS has been declared, but not defined, so it'll always be empty. However, perhaps this isn't the real code OP is really using, which makes troubleshooting the issue pretty much impossible.
|