in reply to Re^2: Best Multidimensional Hash Practices?
in thread Best Multidimensional Hash Practices?
Because it isn't exists that triggers autovivication. It is the (implied or explicitely written) -> operator, as was pointed out in the previous thread by DamianKaelGreen.
Autovivication is exactly the kind of thing that makes this code work:
use strict; use warnings; my $hashRef; # note how it is undefined at this moment! $hashRef->{cogito} = "ergo sum"; print ref $hashRef, "\n" # Output: HASH # Hey... aint that cool? # But we can go even further! $hashRef->{"somewhere"}->{"deep down"}->{"this"}->{"data structure"} = + "I think, so I exist.";
Now, that last line isn't a true beauty but there are those cases that you need deep structures like that. And it really wouldn't be Perlish if you had to make each part of it come into existance manually.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Best Multidimensional Hash Practices?
by almut (Canon) on Oct 13, 2009 at 01:18 UTC | |
by muba (Priest) on Oct 13, 2009 at 02:22 UTC |