I've written a script to parse Apache logs containing cookie data. It enables me to count the number of users and the number of requests they made by populating a hash as I iterate through the log (e.g. $users{$cookie}++;).

The problem I have got is that, because I am using the cookiestring as the hash key it is of unknown length. Now, the only cookie that we set is ~ 30-40 characters but I have run across a couple of instances where Netscrape has dumped the entire cookie file instead of just returning our one. One particular instance led to a would-be key length of ~ 3.5Kb - would-be if SDBM had not shat its pants and ran away crying like a baby!

Is this a bug in SDBM or is there a max key length? If it is SDBM then does anyone know whether any of the other DBM implementations suffer from this problem.

p.s. I am not sitting here wondering how to shorten the string - just curious as to the key length issue.


In reply to SDBM or Perl hash key length restrictions by larryk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.