Workshop

Quiz

1:If there is no package declaration in a Perl program or module, what namespace will subroutines and package variables wind up in?
  1. main

  2. perl

  3. They're not in a package; they're lexical

2:Which of the following is a valid way to end a module?
  1. -1;

  2. “Hello, World!”

  3. return 1;

  4. All of the above

  5. None of the above

3:If you export a subroutine name from a module into a program that already has a subroutine by that same name, which one runs when you call the subroutine? (Try it and see.)
  1. The subroutine from the module

  2. The subroutine from the main program

  3. Neither; the program won't compile.

  4. Neither; the program will compile, but it will crash when you call the ambiguous function.

Answers

A1: a. Generally, anything not declared with my, and not following ...

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.