chris
chris

Reputation: 366

Can someone explain what the actual error is here and how to fix it?

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?

Upvotes: 2

Views: 161

Answers (1)

Alan Curry
Alan Curry

Reputation: 14711

You're trying to use a variable called $mapping that doesn't exist. There is one called %mapping which has an element called $mapping{$outlook} but $mapping if it existed would be an unrelated scalar, not part of the hash.

It looks like you should use $hashref->{$mapping{$outlook}}

Upvotes: 8

Related Questions