CIW Course Revision Site

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.

Q2. You can use namespaces to:

Q3. Where can the package keyword be used in a Perl script?

Q4. What is the name of the default top-level package in Perl?

Q5. What would be the output from the following coding?

$x = 5;
$y = 2;
package sub;
$y = $x + 10;
package main;
print ($x * $y);

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);

Q7. BEGIN and END blocks are case sensitive within Perl scripts.

Q8. An END block is usually used to:

Q9. What would be the output from the following Perl script?

END { print("one "); }
print("two ");
BEGIN { print("three "); }

Q10. What extension is used to identify Perl modules?

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.

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.

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;

Q14. What must a valid Perl module return?

Q15. Typically, the name of the package defined within a module differs from the filename of the module.

Design by Stephen

Certified Internet Webmaster

Page last Edited: 25 Nov 2011