Click to See Complete Forum and Search --> : Newbie to Perl Programming
2wire
03-23-2009, 09:47 PM
I am very new to Perl and I am trying to learn little by little. What statement adds the element (willie, 74) to the hash %fun?
I have no idea what it is asking?
Also how do you get the address of a scalar variable $truck?
And finally, how do you get the address of a list literal?
Jeff Mott
03-24-2009, 12:25 AM
You should ask your teacher these questions.
Sixtease
03-24-2009, 03:43 AM
Or you can ask the perl documentation: perldata (http://perldoc.perl.org/perldata.html#Variable-names) and perlop (http://perldoc.perl.org/perlop.html#Assignment-Operators) tell you about #1. If you don't understand the question, it says:
Say you have a hash, like e.g.
%fun = {
jeff => 32,
sally => 18,
}
which holds the information that Jeff is 32 years old and Sally is 18. Now how do you add the record about Willy stating that he's 74? The resulting hash should look like
{
jeff => 32,
sally => 18,
willy => 74,
}
Again, the links above should help you get the answers, though you may want to read them from start rather than just the parts I gave links to.
Answer for question #2 is in perlref (http://perldoc.perl.org/perlref.html#Making-References).
The third question is tricky and you may conclude the answer from the documents linked here.
Good luck. ;-)