Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:36:11+00:00 2026-06-06T11:36:11+00:00

Could you someone shed some light on the hashing function/algorithm Perl uses to map

  • 0

Could you someone shed some light on the hashing function/algorithm Perl uses to map a string to an index ? Any relevant reading ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:36:13+00:00Added an answer on June 6, 2026 at 11:36 am

    [This answer predates the hashing function change made in 5.28. See “Default Hash Function Change” in the perldelta for 5.28.]

    PERL_HASH_INTERNAL_, defined in hv.h, copied below:

    /* hash a key */
    /* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins
     * from requirements by Colin Plumb.
     * (http://burtleburtle.net/bob/hash/doobs.html) */
    /* The use of a temporary pointer and the casting games
     * is needed to serve the dual purposes of
     * (a) the hashed data being interpreted as "unsigned char" (new since 5.8,
     *     a "char" can be either signed or unsigned, depending on the compiler)
     * (b) catering for old code that uses a "char"
     *
     * The "hash seed" feature was added in Perl 5.8.1 to perturb the results
     * to avoid "algorithmic complexity attacks".
     *
     * If USE_HASH_SEED is defined, hash randomisation is done by default
     * If USE_HASH_SEED_EXPLICIT is defined, hash randomisation is done
     * only if the environment variable PERL_HASH_SEED is set.
     * For maximal control, one can define PERL_HASH_SEED.
     * (see also perl.c:perl_parse()).
     */
    
    #define PERL_HASH_INTERNAL_(hash,str,len,internal) \
        STMT_START { \
           register const char * const s_PeRlHaSh_tmp = str; \
           register const unsigned char *s_PeRlHaSh = (const unsigned char *)s_PeRlHaSh_tmp; \
           register I32 i_PeRlHaSh = len; \
           register U32 hash_PeRlHaSh = (internal ? PL_rehash_seed : PERL_HASH_SEED); \
           while (i_PeRlHaSh--) { \
               hash_PeRlHaSh += *s_PeRlHaSh++; \
               hash_PeRlHaSh += (hash_PeRlHaSh << 10); \
               hash_PeRlHaSh ^= (hash_PeRlHaSh >> 6); \
           } \
           hash_PeRlHaSh += (hash_PeRlHaSh << 3); \
           hash_PeRlHaSh ^= (hash_PeRlHaSh >> 11); \
           (hash) = (hash_PeRlHaSh + (hash_PeRlHaSh << 15)); \
       } STMT_END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone shed some light on where this code is incorrect please <script> chrome.browserAction.onClicked.addListener(function(window)
I've got a couple questions if someone could shed some light. I've written a
Could someone shed some light on why my WndProc method as implemented below isn't
Just wondering if someone could shed some light on a problem I'm having. The
Could someone shed some light on this my NameValueCollection returns the Length property instead
Could someone please shed some light on the workings of A-sort (not asort()), which
Hi wondering if perhaps someone could shed some light on the below error. The
I was just wondering if someone could shed some light on why I am
I would be really grateful if someone could shed some light on this for
I'm having some strange issues with Matches, hoping someone could shed some light. According

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.