Tony Frasketi wrote:
>Both $hash->{$key} and $$hash{$key} work fine and this also works
>Although I'm not sure why.... ${$hash}{$key}.
There is a reason for this. Let's say you had two variables:
%hash (a hash)
$hash (a hash reference)
You could confuse the interpreter if you wrote this:
$$hash{key};
Is that the key of the hash that $hash points to, or a dereference of a
scalar reference contained in the key of %hash? To be more specific,
you can use this syntax.
${$hash{key}} (the scalar referenced by $hash{$key})
${$hash}{$key} ($the key of the hash pointed to by $hash)
I usually leave the brackets in so I don't have to worry about it.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>