reference to specific hash key

Posted by dave on Stack Overflow See other posts from Stack Overflow or by dave
Published on 2010-03-25T04:37:09Z Indexed on 2010/03/25 4:43 UTC
Read the original article Hit count: 502

Filed under:
|
|
|

How do I create a reference to the value in a specific hash key. I tried the following but $$foo is empty. Any help is much appreciated.

$hash->{1} = "one";
$hash->{2} = "two";
$hash->{3} = "three";

$foo = \${$hash->{1}};
$hash->{1} = "ONE";

#I want "MONEY: ONE";
print "MONEY: $$foo\n";

© Stack Overflow or respective owner

Related posts about perl

Related posts about hash