Explain the difference between use and require?
Answer Posted / vipul dalwala
- a require statement imports the functions and objects
only within their defined packages. The use keyword, on the
other hand, imports the functions and objects so they are
available to the current package as if they had been
defined globally. For example,
require Cwd;
$pwd = Cwd::getcwd();
as opposed to
use Cwd;
$pwd = getcwd();
- use statements are interpreted and executed at the time
the file is parsed, but require statements import modules
at run time, which means you can supply a variable name to
a require statement based on other elements of your program.
Is This Answer Correct ? | 9 Yes | 9 No |
Post New Answer View All Answers
What is the use of -n and -p options?
what is the main function of fork() in cgi programming?
You want to add two arrays together. How would you do that?
Is perl compiler or interpreter?
List the files in current directory sorted by size ?
Explain split function in perl?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
Who created perl?
How to check the status of airplane mode (enable/disable) in perl for Android mobile?
Which of these is a difference between Perl and C++ ?
What is q (single q) operator in perl?
What package you use to create a windows services?
How to remove a directory in perl?
What is it meants by '$_'?
What are the reasons that cookie server can’t handle multiple connections?