ChangeManagement has asked for the wisdom of the Perl Monks concerning the following question:
The problem right now is, although I can get access to the arrays again if I access a specific value with a specific key, I can't get access when I just try keys() to start out. E.g.my @multiKey1 = ("a","b"); my @stuff1 = ("1", "2", "3"); my @multiKey2 = ("c","d"); my @stuff2 = ("4", "5"); my @multiKey3 = ("e","f"); my @stuff3 = ("6", "7"); my %testHash = ( \@multiKey1 => \@stuff1, \@multiKey2 => \@stuff2, \@m +ultiKey3 => \@stuff3);
For this, I get the following output, and I don't understand why :-/@testHashKeys = keys %testHash; @testHashValues = values %testHash; $tmp = @testHashKeys; foreach (@testHashKeys){ print "deref bla = @$_ = $_\n"; } foreach (@testHashValues){ print "deref bla = @$_ = $_\n"; } $ref = $testHash{$testHashKeys[0]}; @valueArray = @$ref; print "valueArray = @valueArray\n";
The key thing is the line: print "deref bla = @$_ = $_\n"; If it knows that $_ is an array reference, why doesn't @$_ dereference it to give me the array values printed out, like everywhere says it should, and like happens with the values array? I greatly appreciate you taking the time to read this :)deref bla = = ARRAY(0x10082add0) deref bla = = ARRAY(0x10082afc8) deref bla = = ARRAY(0x10082aed8) deref bla = 1 2 3 = ARRAY(0x10082ae48) deref bla = 6 7 = ARRAY(0x10082b040) deref bla = 4 5 = ARRAY(0x10082af50) valueArray = 1 2 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reference as hash keys and values
by muba (Priest) on Jul 07, 2011 at 00:38 UTC | |
by davido (Cardinal) on Jul 07, 2011 at 02:02 UTC | |
by roboticus (Chancellor) on Jul 07, 2011 at 01:53 UTC | |
|
Re: reference as hash keys and values
by ikegami (Patriarch) on Jul 07, 2011 at 00:43 UTC | |
|
Re: reference as hash keys and values
by locked_user sundialsvc4 (Abbot) on Jul 07, 2011 at 02:32 UTC | |
|
Re: reference as hash keys and values
by CountZero (Bishop) on Jul 07, 2011 at 15:42 UTC | |
by Don Coyote (Hermit) on Jul 10, 2011 at 21:20 UTC | |
|
Re: reference as hash keys and values
by armstd (Friar) on Jul 11, 2011 at 05:08 UTC |