This reports syntax error:
$hash={a=>2};
print %{$hash}{a};
But this works:
print each(%{$hash})
Why??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get an element from a hashref, you take the normal code for getting a hash element:
$foo{'bar'}, and replace the name of the hash, not including the sigil, with the hashref:$$hash{'bar'}. Your%would only be used to dereference to the full hash, as in your each case, not just an element.More helpful hints at http://perlmonks.org/?node=References+quick+reference.