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 are the different ways to run cgi?
What are prefix dereferencer?
What is -> symbol in perl?
What does redo statement do in perl?
What is the difference between use and require in perl?
What is the main function of cookie server?
How do I send e-mail from a Perl/CGI program on a Unix system?
What value is returned by a lone `return;’ statement?
Which functions in perl allows you to include a module file.
What are stdin, stdout and stderr?
How to create a package?
Explain use of ‘my’ keyword in perl?
What are the advantages of programming in perl?
How do I replace every character in a file with a comma?
What are the various uses of perl?