introduction to web programming 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);


     @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").

Previous | Next | Table of Contents