gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
Note that the k2 ($hash->{key1}{key2}) is printed! But k1 ($hash->{key1}) already exist, and isn't a HASH ref!my $hash = {} ; $hash->{key1} = 'k1' ; $hash->{key1}{key2} = 'k2' ; print ">> $hash->{key1}\n" ; print ">> $hash->{key1}{key2}\n" ; __OUTPUT__ >> k1 >> k2
What should happens is to exist only one option, k1 or k2! Not the both! I found the error using Storage, to save the HASH tree in a file. But Storage only save k1, like should be. In other words, k2 only exist in the memory, not in the HASH tree.
If you try to test the ref() of $hash->{key1} you also get undef.
Soo, is this documented? Is right or wrong? How to know if k1 is also a HASH ref?
Please, test the code and see if this output works in other OS too (tested on Win32 only).
Note that this only work for HASH reference, if you use %hash, work normal.
Graciliano M. P.
"The creativity is the expression of the liberty".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange HASH reference BUG! Dual value for a key with sub-key!
by grep (Monsignor) on May 21, 2003 at 06:40 UTC | |
|
Re: Strange HASH reference BUG! Dual value for a key with sub-key!
by BrowserUk (Patriarch) on May 21, 2003 at 06:43 UTC | |
|
Re: Strange HASH reference BUG! Dual value for a key with sub-key!
by djantzen (Priest) on May 21, 2003 at 06:45 UTC | |
|
Re: Strange HASH reference BUG! Dual value for a key with sub-key!
by mce (Curate) on May 21, 2003 at 06:58 UTC |