in reply to Problem de-referencing a variable
my @array = @{ $key }; print join ",", @array;
should be
my @array = @{ $reverse_translation{key} }; print join ",", @array;
But that wastefully copies the array. Just work with the array reference:
my $array = $reverse_translation{key}; print join ",", @$array;
Update: Oops, I missed the fact that you reversed the keys and values.
While the above does solve a problem, you are also running afoul of the restriction that hash keys (for untied hashes) can only be strings. When you attempted to use an array reference as a key, a string representation of the array reference was used as the key rather than the array reference itself. So when you tried to deference the keys, you were trying to dereference a string.
What are you trying to accomplish by reversing the hash? Would the following do?
foreach my $key (keys %translation) { print("$key: "); print(join(",", @{ $translation{$key} })); print("\n"); }
|
|---|