3.4. Arrays and Hashes
A hash is a mapping from distinct keys to individual values, and is most commonly used as a random-access look-up table. On the other hand, arrays are usually ordered sequences of multiple values, and are most commonly processed collectively or iteratively. Because hash entries are typically accessed individually, it makes sense for the hash itself to be named in the singular. That convention causes the individual accesses to read more naturally in the code. Moreover, because hashes often store a property that's related to their key, it's often even more readable to name a hash with a singular noun followed by a preposition. For example: my %option; my %title_of; my %count_for; my %is_available; On the other hand, array values are more often processed collectively, in loops or in map or grep operations. So it makes sense to name them in the plural, after the group of items they store: my @events; my @handlers; my @unknowns; If, however, an array is to be used as a random-access look-up table, name it in the singular, using the same conventions as for a hash: |