Perl values Function
This function returns the list of all the values contained in HASH. In a scalar context, returns the number of values that would be returned. Uses the same iterator, and therefore order, used by the each and keys functions.
Following is the simple syntax for this function:
This function returns number of values in the hash in scalar context and list of value in list context.
Following is the example code showing its basic usage:
#!/usr/bin/perl -w %hash = ('One' => 1, 'Two' => 2, 'Three' => 3, 'Four' => 4); @values = values( %hash ); print("Values are ", join("-", @values), "\n"); @keys = keys( %hash ); print("Keys are ", join("-", @keys), "\n");
When above code is executed, it produced following result
Values are 4-3-2-1 Keys are Four-Three-Two-One