Please send questions to st10@humboldt.edu .
#!/usr/bin/perl -w

#######################################################
# lab02_hash_functs2
#
# try out another of Perl's hash functions: exists, delete
#
# modified by Sharon Tuttle from "Learning Perl",
#    by Schwartz and Phoenix
#
# last modified: 9-2-04
#######################################################

%order_totals = ("chocolate"=>13, 
                 "hamburger"=>10, 
                 "tofu dog"=>12,
                 "fried chicken"=>0,
                 "pizza"=>0,
                );

# ask user to enter a food for which they'd like to see a total

print "for what food do you want to see a total? \n";

chomp($food = <STDIN>);

if (exists $order_totals{$food} )
{
    print "there have been $order_totals{$food} order(s) for $food\n";
}
else
{
    print "sorry, $food is not one of our menu items.\n";
}

# ask user to enter a food to delete from the hash

print "\nenter a food to be deleted:\n";
chomp($food_to_delete = <STDIN>);

delete $order_totals{$food_to_delete};

print "\nHere are remaining foods and their totals:\n";

foreach $food (sort keys %order_totals)
{
    print "$food => $order_totals{$food}\n";
}


# end of lab02_hash_functs2