what is the difference between require and use in perl?
Answers were Sorted based on User's Feedback
Answer / jayakumar.b
use:
* Object Verification will happen @ Compile Time.
* File will have extention of .pm
* Module location will be set by @ISA Variable.
require:
* Object Verification will happen @ Run TIme.
* Method can be used from and .pm or .pl file.
* Absolute path to be given, if file located in different
dir.
| Is This Answer Correct ? | 13 Yes | 2 No |
Answer / rani
use:
1-its compile time concept & refresh the namespace for
different package loading.
Require:
it is run time concept & does not refresh the namespace for
different package loading.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / vinoth_bksys
The differences are many and often subtle:
* use only expects a bareword, require can take a
bareword or an expression
* use is evaluated at compile-time, require at run-time
* use implicitly calls the import method of the module
being loaded, require does not
* use excepts arguments in addition to the bareword (to
be passed to import), require does not
* use does not behave like a function (i.e can't be
called with parens, can't be used in an expression, etc),
whereas require does
| Is This Answer Correct ? | 1 Yes | 1 No |
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
How to concatenate strings with perl?
Explain perl one-liner?
Explain USE and REQUIREMENT statements?
What is the syntax used in Perl grep function?
How to merge two arrays in perl?
How to add elements in a hash in perl?
Explain the functioning of conditional structures in perl.
Differentiate between use and require, my and local, for and foreach and exec and system
What is -> symbol in perl?
Explain strftime() function in perl?
What happens when you return a reference to a private variable?