Hash

From Alteeve Wiki
Jump to navigation Jump to search

 AN!Wiki :: Hash

A hash table, also known as a dictionary, is a programmatic way of storing elements in a way that allows their retrieval by using a named key. This allows a program to not worry about where in the hash an element is at any given time as it's position is irrelevant to it's retrieval.

  • Hash tables are generally slower than arrays.

Hash tables are often expressed in the following format:

  • Creating a hash table with four key/value pairs.
hash=(
       some_key    => "first_element",
       another_key => "foobar",
       this_key    => 12,
       that_key    => "30.5"
)
  • Retrieving one of the elements by using the associated key name.
print hash{that_key};   # Would print "30.5".

In Perl, hashes are prefixed with the '%' symbol.

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.