In
Tie::Cache, there is a (private) method
_get_data_length, which tries to estimate the total memory used by a HASH, SCALAR, or ARRAY. It recursively traverses the structure, adds a guess of the overhead needed, and uses the
length function to determine "content" length. You might be able to use this function to come close, or use it as a springboard to writing your own.
--JAS