Tutor Marked Assignment PL TMA-08
In a Nutshell - CIW Course Section 2 Part B
PL TMA-08 - CD Access Code: 21156
Q1. Ordinarily, scalar variables that are defined within the body of a Perl script cannot be accessed by any of the subroutines defined within the same file.
- a) True
- b) False
Q2. You can use namespaces to:
- a) Organise your code
- b) Ensure readability
- c) Prevent errors
- d) Define subroutines
Q3. Where can the package keyword be used in a Perl script?
- a) Only at the beginning
- b) Only before subroutines
- c) Only at the end
- d) Anywhere
Q4. What is the name of the default top-level package in Perl?
- a) main
- b) major
- c) core
- d) block
Q5. What would be the output from the following coding?
$x = 5;
$y = 2;
package sub;
$y = $x + 10;
package main;
print ($x * $y);
- a) 75
- b) 60
- c) 50
- d) 10
Q6. What would be the output from the following coding?
$x = 5;
$y = 2;
package sub;
$y = $x + 10;
package main;
print ($x * $sub::y);
- a) 75
- b) 60
- c) 50
- d) 10
Q7. BEGIN and END blocks are case sensitive within Perl scripts.
- a) True
- b) False
Q8. An END block is usually used to:
- a) Display error messages
- b) Close file handles
- c) Load Perl modules
- d) Open file handles
Q9. What would be the output from the following Perl script?
END { print("one "); }
print("two ");
BEGIN { print("three "); }
- a) one two three
- b) two three one
- c) three two one
- d) three one two
Q10. What extension is used to identify Perl modules?
- a) .pl
- b) .pm
- c) .pn
- d) .po
Q11. Rather than use the package symbol table, the use statement can add symbols or a select list of symbols directly to the symbol table of the including package. To enable this facility, the module must be set to include the ________ module.
- a) Importer
- b) Exporter
- c) Interior
- d) Exterior
Q12. The use statement is sometimes preferred to the require statement because it looks for modules during compilation so that you are alerted to mistakes earlier.
- a) True
- b) False
Q13. What is the output from the following coding?
package top;
$a = 2;
$b = 5;
package middle;
$b = $a + 2;
$c = $b - 1;
package bottom;
$a = 3;
$b = $middle::c + $top::a;
print $a + $b;
- a) 4
- b) 5
- c) 6
- d) 7
Q14. What must a valid Perl module return?
- a) The package name
- b) The names of the subroutines within it
- c) A false value
- d) A true value
Q15. Typically, the name of the package defined within a module differs from the filename of the module.
- a) True
- b) False

