in reply to Re^2: creating defined references to arrays of size zero
in thread creating defined references to arrays of size zero
hash = { a=>[]; b=>[] c=>[] . . . } #some time later my $key = "alpha" my $array = $hash->{$key};
At this point there isn't anything at $hash->{$key}, so $array isn't pointing to anything real. When I push onto $array, that memory will get allocated happily, and won't create anything in the hash (which is a very good thing). If instead, the first thing I do is to shove something into @{$hash->{$key}}, a new entry gets magically allocated, and then everything works as expected.
Obviously I'm not one with the perl yet.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: creating defined references to arrays of size zero
by NetWallah (Canon) on Jul 14, 2005 at 17:32 UTC |