Perl Hash Values List, values() Function
What is values() Function in Perl programming?
Explanation
The values() function is used to return a list of the values in a hash.
Syntax:
values hash;
Example :
#! C:programfilesperlbinperl
print "content-type: text/htmlnn";
%emp = ('empno' => '12422' , 'empname' => 'Kate Anderson',
'empph' => '9167552148', 'empcode' => 'ADS212');
foreach $value (values %emp)
{
print "$valuen";
}
Result :
ADS212 Kate Anderson 9167552148 12422
In the above example using the values() function all the values of the hash "emp" is displayed using a for each loop.