programming-examples/perl/Hash/Hash (Associative Array) Functions- The keys function returns, in random order, the keys of a hash.pl
2019-11-15 12:59:38 +01:00

17 lines
467 B
Perl

#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";