Perl is telling you exactly what is wrong. You have used the strict
pragma, so using the %hash
variable without declaring it is a syntax error. While the string %hash
does not appear in your code, the string $hash{...}
does, on each of the problem lines. This is the syntax to access an element of the %hash
, which is why strict is complaining.
You have declared the variable $hash
, so accessing an element of the contained hash reference is written $$hash{...}
or $hash->{...}
. Fix the problem lines to access the correct variable and the code will compile.
1
solved How to create hash with duplicate keys