Perl Programming/Keywords/values
Appearance
The values keyword
[edit | edit source]values returns a list of all the values of the named HASH, when called in list context. Using Perl 5.12 or later, it will also return a list of the ARRAY. Older versions would produce a syntax error. If called in scalar context, values returns the number of values in the object.
A side effect is that any call on an ARRAY or a HASH will reset the internal iterator of the object. If called in void context resets only the iterator. In list context, values @array is the same as @array.
The values are returned as call-by-reference, so any modification to the elements would change the object content.
From Perl 5.14 onwards, values can evaluate an EXPRESSION that should have the reference to an unblessed hash.
Syntax
[edit | edit source] values HASH
values ARRAY
values EXPRESSION
Examples
[edit | edit source]