#!/usr/bin/perl
#w4.6.pl  hash assignment, keys, values, each

%colors = (Jim,green,Floyd,red,Fred,blue,Jane,yellow,Marta,pink);
$colors{Zeke} = purple;
$colors{Zena} = plum;

print ("$colors{Jim}\n\n");

print keys (%colors);
print ("\n\n");

print values (%colors);
print ("\n\n");

@names = keys (%colors);
foreach (@names){
     print ("$_ ");
     }
print ("\n\n");

foreach (keys(%colors)){
     print ("$_ ");
     }
print ("\n\n");



foreach (sort(keys(%colors))){
     print ("$_ ");
     }
print ("\n\n");

foreach (keys(%colors)){
     print ("$_ is $colors{$_}\n");
     }
print ("\n\n");

while (($name,$color) = each(%colors)){  	#more efficient, but no sort
   print  ("$name is $color\n");
}

__END__

