One example of a hash function is that used by the programming language Perl. This hash function is used by Perl (prior to version 5.6) to produce integer indices for associative arrays (aka hash tables) the programmer defines in a Perl program.

Here's an implementation of it in C. Here, the char* pointer str points to an ASCII string which is the textual index given by the programmer which we assume has already been given a value.

/* variable definitions */
unsigned int hash = 0;
unsigned long int len = strlen(str);
char *s = str;

/* make the hash */
while (len--) {
        hash = (hash * 33) + *s;
        s++;
}

Perl then folds the given value such that it is less than the size of the array.