I’m trying to use a hash in a nested for/foreach loop. see Source
With strict it says
Global symbol "$mapping" requires explicit package name at ./test2.pl line 39.
Execution of ./test2.pl aborted due to compilation errors.
Without strict,
Use of uninitialized value $mapping in hash element at ./test2.pl line 46, <$fh> line 8.
Use of uninitialized value in concatenation (.) or string at ./test2.pl line 46, <$fh> line 8.
print $hashref->{$mapping} is empty in the output.
What is the error?
You’re trying to use a variable called
$mappingthat doesn’t exist. There is one called%mappingwhich has an element called$mapping{$outlook}but$mappingif it existed would be an unrelated scalar, not part of the hash.It looks like you should use
$hashref->{$mapping{$outlook}}