I will point out that any kind of structure that you'd want, say like a binary-tree or whatever can be implemented in Perl. In no way are you limited to the basic "built-in" data types.
Of course there will be a trade-off between performance and memory size. In general if you have enough memory, don't make that tradeoff! Of course besides reducing speed, this adds complexity which normally is not good unless you really need it!
If you have say a whole bunch of objects that you'd like to store more efficiently, then look at ObjectTemplate.
If you are starting to get "into the guts", then I would recommend "Advanced Perl Programming" by Srinivasan.
Anyway back to original question: the key and value are both stored. There isn't any super tricky thing that "re-uses" strings via a pointer to that string. If that happened, then it would be necessary to keep track of where that string was used before and then to "split it into 2 strings" if you changed it in one place and not in another. So if you use string "bcd" in one hash and "bcd" in another other hash (maybe a subhash or the first hash) as a key, that string "bcd" is replicated.
Anyway this is getting into a complex subject and I go back to my question: why does this matter to you?
In reply to Re: Hash key or value string reuse?
by Marshall
in thread Hash key or value string reuse?
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |