Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Filling a hash

by inman (Curate)
on Oct 26, 2005 at 09:00 UTC ( [id://502981]=note: print w/replies, xml ) Need Help??


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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://502981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found