#!/bin/perl

# This example demonstrates the use
# of a HASH data type, with WHILE and
# FOREACH control structures.


#####################################
# FIRST PART
#####################################
%characters = ("diver", "Kino", 
               "wife",  "Juana", 
               "child", "Coyotito");

#####################################
# SECOND PART
# Print all the characters 
#####################################
print "print %characters\n";
print %characters;
print "\n";
print "\n";

#####################################
# THIRD PART
# Print just the keys
#####################################
print "printing just the keys: \n";
foreach $key (keys %characters)
   {
      print "$key \n";
   }
print "\n";

#####################################
# FOURTH PART
# Print just the values 
#####################################
print "printing just the values: \n";
foreach $x (values %characters)
   {
      print "$x \n";
   }
print "\n";

#####################################
# FIFTH PART
# Print just the name of the child
#####################################
print "printing just the name of the child: \n";
print "$characters{child}\n\n";

#####################################
# SIXTH PART
# Printing each key, value pair in the characters hash
#####################################
print "Printing each key, value pair in the characters hash\n";
   
while (($key, $val) = each (%characters)) 
   {
      print "Key: $key, Value: $val \n";
   }

#####################################
# ON YOUR OWN 
# 1. Print the name of the diver 
# 2. Print the key and value of all
#    characters who's name is not
#    "Kino"
#####################################
