next up previous contents index
Next: Summary Up: Perl data structures Previous: Arrays or Lists

Hashes

  Like in TCL , associative arrays -- which are here called hashes -- have been implemented in  perl , too. They are similar to arrays, but any scalar valuegif can be used as an index. As mentioned before, all hashes have to start with the character %. Their index is given in curly braces.

Perl has three functions to handle hashes, defined, exists, and delete. Those functions test if a given key is defined, if there is an entry existing for a defined key, and last, but not least, delete one entry.

One important thing to keep in mind when working with hashes is that  perl uses hashing to allow an efficient access of the stored elements. Due to this, it is not possible to find out in which order the hash has been constructed. It is possible to convert hashes to arrays and vice versagif, but the order will nearly always be lost.



Ingo Melzer
Mon Aug 5 15:12:01 MET DST 1996