Hash (Associative Array) Functions: The keys function returns, in random order, the keys of a hash.
#Format:
#keys(ASSOC_ARRAY)
#keys ASSOC_ARRAY
# The keys function returns the keys of a hash
%weekday= ( '1'=>'Monday',
'2'=>'Tuesday',
'3'=>'Wednesday',
'4'=>'Thursday',
'5'=>'Friday',
'6'=>'Saturday',
'7'=>'Sunday',
);
foreach $key ( keys(%weekday) ){print "$key ";}
print "\n";
foreach $key ( sort keys(%weekday) ){print $key ;}
print "\n";
Related examples in the same category