This question is asked in many technical interviews which required knowledge of perl.
Require:
- Usage: require EXPR
- if EXPR is a numeric value, then script demands that i requires specified version of perl.
- if EXPR is not numeric, then i assumes that EXPR is name of file to be included in script.
- The included file must return true as last statement.
- file extension should be specified.
- Can be used to load libraries as well as packages.
- file will be loaded and verified at run time.
- require creates namespace with name as EXPR and function and variables of package will be referred as EXPR::variable or EXPR::function
- package name should be specified with .pm extension
Use:
- Usage: use EXPR
- if EXPR is a numeric value, then script demands that i requires specified version of perl.
- if EXPR is not numeric, then i assumes that EXPR is name of file to be included in script.
- The included file must return true as last statement.
- file extension need not to be specified.
- Can be used to import packages only.
- package will be loaded and verified at compile time.
- No new namespace will be created. All functions and variables from package will be added to main namespace.
- use "Module" is equivalent to:
require "Module.pm"
Module->import()
No comments:
Post a Comment
Please Comment for Any question or suggestions