Yeah, works for me as well. Perhaps your confusion is with %$hr{a} which would be trying to dereference a hashref contained in the hash %hr in the value associated with the key "a".
use Data::Dumper qw( Dumper ); $hash_a->{a} = "hello" ; @$hash_b{a} = "hello" ; $arr_a->[0] = "hello" ; @$arr_b[0] = "hello" ; print "hash_a ", Dumper( $hash_a ), "\n"; print "hash_b ", Dumper( $hash_b ), "\n"; print "arr_a ", Dumper( $arr_a ), "\n"; print "arr_b ", Dumper( $arr_b ), "\n"; __END__ hash_a $VAR1 = { 'a' => 'hello' }; hash_b $VAR1 = { 'a' => 'hello' }; arr_a $VAR1 = [ 'hello' ]; arr_b $VAR1 = [ 'hello' ];
In reply to Re: A better understanding of array and hash references
by Fletch
in thread A better understanding of array and hash references
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |