If there is no package declaration in a Perl program or module, what namespace will subroutines and package variables wind up in?
They're not in a package; they're lexical
Which of the following is a valid way to end a module?
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.)
The subroutine from the module
The subroutine from the main program
Neither; the program won't compile.
Neither; the program will compile, but it will crash when you call the ambiguous function.
a. Generally, anything not declared with my, and not following a package declaration, is in the namespace main.
d. All of the above. In Perl, a module must end in a statement that has a true value. The only false values in Perl are zero, undef, and the empty string. The traditional way is with 1;.
b. All use statements are processed during compile-time. Momentarily, the module's subroutine would have taken precedence. Later in the compilation it is replaced with the local version of the subroutine.
Expand on the File Information module to include subroutines to return the type of file (text or binary), the contents of the file (as an array), and the directory name of the file if available. This module will be revisited in the next hour, so choose good extensions.
© 2000- NIV