Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: call perl hash function?

by dbp (Pilgrim)
on Jan 26, 2003 at 20:28 UTC ( [id://230026]=note: print w/replies, xml ) Need Help??


in reply to call perl hash function?

From the perlguts manual:

The hash algorithm is defined in the "PERL_HASH(hash, key, klen)" macro:

hash = 0; while (klen--) hash = (hash * 33) + *key++; hash = hash + (hash >> 5); /* after 5.6 */
The last step was added in version 5.6 to improve distribution of lower bits in the resulting hash value.

If you just want a look at the hashing function, this is it. A look at the full source might give you a better feel for it. If you want to call this from perl, you can use Inline::C which automatically includes perl.h. Alternatively, you can reimplement this function in pure perl and use it from there.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://230026]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-06-24 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.