Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I've made a quick search, but didn't find what I needed. Please point out relevant references if you got 'em.

I have a very large hash tree structure, with a lot of duplicate strings as either keys or values (depends on the sub tree). I'm using DBM::Deep for persistence, but I also run the script in memory mode, so this issue is equally valid for both.

I'm looking to reduce the overall hash size by, for instance, creating a subhash with the common value strings, and having the values point to the common string sub hash. Does Perl already do something like this for me behind the scenes?

What would I do for common key strings (in subtrees, of course)?

[The hash contains both numeric and string data. String data is sometimes short, like "N/A", or a filename, or 200+ bit bitstring that can't be represented numerically. The bitstrings tend to be similar, and there's a lot of duplicates.]

-QM
--
Quantum Mechanics: The dreams stuff is made of


In reply to Hash key or value string reuse? by QM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found