In perltoot is this code:
$rec = {
name => "Jason",
age => 23,
peers => [ "Norbert", "Rhys", "Phineas"],
};
Is this a string or some sort of hash (I thought hashes were declared with %)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a reference (sort of a pointer) to a hash. And a reference (as anything that begins with ‘$’ in Perl) is an scalar, in this case a scalar that “points” to a non-scalar value.
Understanding references is essential to any more than casual Perl programming. For example, you need to use references to make nested structures ( arrays of arrays, etc).