Tutorials Point


  Perl Home

  PERL Functions

© 2013 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL values Function



Advertisements

Syntax

values HASH


Definition and Usage

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.

Check keys() function also

Return Value

  • In scalar context - Number of values in the hash

  • In list context - List of values

Example

#!/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");

It will produce following results:

Values are  4-3-2-1
Keys are Four-Three-Two-One


Advertisements


  

Advertisements