![]() This keys () function allows you to get a list of keys of the hash in scalars which can be further used to iterate over the values of respective keys of the hash. Maybe this is what you really will gather all the unique values in your array and make them hash-keys pointing to a numerical value representing how many times they occured in the array. In Perl, hash data structure is provided by the keys () function similar to the one present in Python programming language. Or is the array-value going to become the hash value, and something else is the key. ![]() How do you want your array to map into the hash? Are you basically just trying to root out double entries in an array? If that is the case, then the array-value will be the hash-key, and it will point to a count of occurences. Example: /usr/bin/perl age ('Chaitanya Singh' > 29, 'Ajeet' > 28, 'Lisa' > 25) my k keys age print 'Keys: k ' Output: Keys: Ajeet Chaitanya Singh Lisa 2) values function: values function returns the list of all the values in a hash. A hash is like two lists, where one list is the hash-keys, and the other list is the hash-values. 21:58:51 Commit Hash: fb16dfe People watching this port. Useful Hash functions: 1) keys function: keys function returns the list of all the keys in a hash. Question: An array is simply a list of values. You want to populate a hash with those values. ![]() I'm still really unclear on exactly what you are desiring. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |