Perl | Useful Hash functions Last Updated : 30 Jun, 2019 Comments Improve Suggest changes Like Article Like Report A hash is a set of key-value pairs. Perl stores elements of a hash such that it searches for the values based on its keys. Perl provides various functions to perform operations on Hashes, such as to return values of the hash, to delete elements from a hash, etc. Example: Perl #!/usr/bin/perl # Initializing hash %hash1 = ('Welcome' => 10, 'to' => 20, 'Geeks' => 80); # To delete the List passed as parameter $deleted_element = delete($hash1{'to'}); # Printing elements of Hash print "$hash1{'Welcome'}\n"; print "$hash1{'to'}\n"; print "$hash1{'Geeks'}\n"; # Printing the deleted element print "Deleted element: $deleted_element"; Output: 10 80 Deleted element: 20 Some useful functions for hash operations in Perl are listed below: Function Description values() Returns the list of all the values stored in a Hash keys() Returns all the keys of the HASH as a list each() Returns a Two-element list consisting of the key and value pair in List context and key for the next element when called in scalar context delete() Used to delete the specified keys and their associated values from a hash, or the specified elements in the case of an array Comment More infoAdvertise with us Next Article Perl | Useful Hash functions A Abhinav96 Follow Improve Article Tags : Perl Perl-hashes Perl-Hash-Functions Similar Reads Perl | Useful File-handling functions Perl was originally developed for the text processing like extracting the required information from a specified text file and for converting the text file into a different form. These operations can be performed by the use of various inbuilt file functions. Example: Perl #!/usr/bin/perl # Opening a 2 min read Perl | values() Function values() Function in Perl returns the list of all the values stored in a Hash. In a scalar context it returns the number of elements stored in the Hash. Note: Values returned from the value() Function may not always be in the same order. Syntax: values Hash Returns: list of values in the list contex 2 min read Perl | keys() Function keys() function in Perl returns all the keys of the HASH as a list. Order of elements in the List need not to be same always, but, it matches to the order returned by values and each function. Syntax: keys(HASH) Parameter: HASH: Hash whose keys are to be printed Return: For scalar context, it return 1 min read Perl | each() Function This function returns a Two-element list consisting of the key and value pair for the next element of a hash when called in List context, so that you can iterate over it. Whereas it returns only the key for the next element of the hash when called in scalar context. Syntax: each MY_HASH Parameter: M 1 min read Perl Hash A hash is a set of key-value pairs. Perl stores elements of a hash such that it searches for the values based on its keys. Hash variables start with a '%' sign. Perl requires the keys of a hash to be strings, whereas the values can be any scalars. These values can either be a number, string or refer 4 min read Perl - Creating a Hash from an Array Hashing is the process of converting a given key into another value. A hash function is used to generate the new value (called hash) according to a mathematical algorithm. A Perl hash is defined by key-value pairs. Perl stores elements of a hash in such an optimal way that you can look up its values 4 min read Perl | Hashes Set of key/value pair is called a Hash. Each key in a hash structure are unique and of type strings. The values associated with these keys are scalar. These values can either be a number, string or a reference. A Hash is declared using my keyword. The variable name is preceded by the dollar sign($)f 5 min read Applications of Hashing In this article, we will be discussing of applications of hashing.Hashing provides constant time search, insert and delete operations on average. This is why hashing is one of the most used data structure, example problems are, distinct elements, counting frequencies of items, finding duplicates, et 5 min read Hash Functions and Types of Hash functions Hash functions are a fundamental concept in computer science and play a crucial role in various applications such as data storage, retrieval, and cryptography. A hash function creates a mapping from an input key to an index in hash table. Below are few examples. Phone numbers as input keys : Conside 5 min read What are Hash Functions and How to choose a good Hash Function? What is a Hash Function?A hash function is a function that converts a given large number (such as a phone number) into a smaller, practical integer value. This mapped integer value is used as an index in a hash table. In simple terms, a hash function maps a large number or string to a small integer 4 min read Like