117 Homework Assignment #7
03/20/06
Write a perl program to do the following:
- Create a hash with these initial keys and values:
blue 5.62
red 6.50
green 4.27
- Do the following in a loop:
Ask the user to enter a color.
If the color is already in the hash,
display the cost of that color paint.
else
If the user input contains any non-lower case letters,
display an error msg,
else
Ask the user for the cost of that color paint.
If the user input contains any chars other than
digits or an optional single period,
display an error msg
else
add the new color and cost to the hash.
If the user enters the word: done
when asked for a color,
end the loop.
- Then Write all the colors and their values to a text file
named: file7.txt
in the current directory.
Put the color on one line
and the cost on the next line.
|| Then the next color on the next line
|| then its cost on the next line
|| and so on.
- Your program must include
use strict;
use warnings;