Using the keys and values functions 

Using the keys and values functions 
  • Perl also provides a convenient way to get a list of all the keys or of all the values in an associative array if you are interested in more than just one key/value pair. Keys and values are accessed with the keys and values functions using the following formats: 
  • @associative_array_keys = 
    keys (%ASSOCIATIVE_ARRAY_NAME); 
  • and 
  • @associative_array_values = 
    values (%ASSOCIATIVE_ARRAY_NAME); 
  • Thus, the keys and values list of the associative array %CLIENT_ARRAY defined above can be generated with the following syntax: 
  • @client_array_keys = keys (%CLIENT_ARRAY); 
    @client_array_values = values (%CLIENT_ARRAY); 
  • In this example @client_array_keys would look like ("full_name", "phone", "age") and @client_array_values would look like ("Selena Sol", "213-456-7890", "27"). 

Additional Resources:

Accessing an Associative Array
Table of Contents
Adding to and deleting from an associative array


Graphics & Media Lab. >> Библиотека | Курсы | Графикон

Hosted by Graphics & Media Lab
http://graphics.cs.msu.su
lab_logo
mailto: Laboratory