Good solution... however, what if it's a multi-dimensional hash? Perhaps a recursive function that'll traverse the tree and find the number of bytes in each branch and eventually return it to the top?
However, I believer perl requires quite a few bytes extra for storing each scalar, as well as even more bytes to keep track of hash mappings, so if the purpose of this proposed chunk of code is to help work out memory constraint on a system, the value it returns will be optimistically low at best.
"Falling in love with map, one block at a time."
-
simeon2000