NAME

Question types


Start with


Question limit

of 17 available terms

Print test

17 True/False questions

  1. What are lexical variables?Package variables are globally accessible and what you get when you don't use 'my' in a variable declaration.

    A package variable name has both a package qualifier which says what package (or namespace) the variable is in and the variable name. If left off, the current package is used for the package qualifier.

          

  2. How do you make Perl require that package variables require an package qualifier?{
    no strict 'vars';
    # strict vars are now off for the rest of the block
    }

          

  3. What is the scope of a Perl lexical variable?A package declaration is lexically scoped just like variables declared with the 'my' operator.

          

  4. What does 'local' do?'my' creates a variable (if one of the same name doesn't already exist within the same scope of the 'my') whose lexical scope is from the point of the 'my' to the end of the block.

          

  5. What is the difference between 'our' and 'use vars'?'my' creates a new localized (or lexical) variable, but 'local' does not.

    'local' hides the value of an existing package variable and restores it at the end of the block that 'local' appear in.

          

  6. How is the current package set?Using a package delcaration:
    package $package_name;

          

  7. What is the default package in Perl?Using a package delcaration:
    package $package_name;

          

  8. What are the two ways to explicitly refer to a variable in the default package?You can refer to a variable in the default package either like this: '$main::x' or like this: '$::x'.

          

  9. What is a package variable?Package variables are globally accessible and what you get when you don't use 'my' in a variable declaration.

    A package variable name has both a package qualifier which says what package (or namespace) the variable is in and the variable name. If left off, the current package is used for the package qualifier.

          

  10. What does 'use vars()' do?'local' saves the current value of the specified package variable in a safe place and replaces it with a new value (or with undef if no new value was specified). It also arranges for the old value to be restored when control leaves the current block.

          

  11. How can you turn off strict vars for the scope of one block?Using a package delcaration:
    package $package_name;

          

  12. What variables are always forced to be in the main package?In Perl, the scope of a lexical variable is from the point the variable is declared with 'my' to the end of the block the variable was declared in. If the variable wasn't declared in any block, its scope is from the place it was declared to the end of the file.

          

  13. What is the symbol table?Global symbols (such as Package variables) reside in a symbol table. There is one symbol table for each package, (which is why global symbols are really package global symbols).

    Lexical variables are not in a symbol table. Because of this, they are not available from outside the block in which they are declared.

          

  14. Explain the difference between 'my' and 'local''my' creates a new localized (or lexical) variable, but 'local' does not.

    'local' hides the value of an existing package variable and restores it at the end of the block that 'local' appear in.

          

  15. What does an 'our' declaration do?'my' creates a variable (if one of the same name doesn't already exist within the same scope of the 'my') whose lexical scope is from the point of the 'my' to the end of the block.

          

  16. What is the scope of a package declaration?A package declaration is lexically scoped just like variables declared with the 'my' operator.

          

  17. What does 'my' do?'local' saves the current value of the specified package variable in a safe place and replaces it with a new value (or with undef if no new value was specified). It also arranges for the old value to be restored when control leaves the current block.