Workshop

Quiz

1:What does $ref contain after the statement $ref=\"peanuts";?
  1. Nothing. That syntax isn't valid.

  2. peanuts

  3. A reference to an anonymous scalar.

2:What does this structure create?
$a=[
    { name=> "Rose", kids=> [ qw( Ted Bobby John ) ] },
    { name=> "Marge", kids=>[ qw( Maggie Lisa Bart ) ] },
];
  1. A hash of hashes, which contains a list

  2. A list of hashes, which contains a list

  3. A list of lists, which contains another list

Answers

A1: c. A reference can be taken to any value, not just scalar, array, and hash variables. You can take references to a number also with $ref=\100;. If you answered a, it's a good idea to try new things with a short program or in the debugger to see what they do if you're unsure.
A2: b. This structure wasn't covered explicitly ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.