in reply to Filling a hash
I need to generate a hash.
You need to declare the hash first if you want extra marks.
The program asks the user to enter elements
You will have to collect user input. This can come from a file, the keyboard or other device. read about <STDIN> for more details.
until they enter 'exit' which stops the loop.
you need to check the input for the word 'exit'. If you are only covering hashes at this stage then you will want to use a string equality operator
Then each hash is printed to the screen.
This is up to you but look at the keys function. This gives you a list of the keys in the hash which you can use to iterate through the hash printing the values one at a time.
The function 'push' is not allowed.
I guess you covered this in the last lesson and the teacher wants you to do something different...
|