A hash variable contains a collection of key/value pairs, arranged such that you can easily use any key to find its associated value.

The order of the key/value pairs in the hash is not important.

Hashes are also called associative arrays.

Comparison between an array and a hash:

ElementsScalar dataScalar data ("values")
IndexesSuccessive integers, starting from 0Arbitrary scalars ("keys")
Element orderMattersArbitrary


Hash variable names start with a % sign.

You may use in the same program a variable named $var and another variable named @var, and a third variable named %var, and they will mean three different, unrelated things.

Table of Contents.