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
List all the features of perl programming?
What is it meants by '$_'?
What can be done for efficient parameter passing in perl?
Explain use of ‘my’ keyword in perl?
What does `new $cur->{LINK}' do? (Assume the current package has no new() function of its own.)
How to open and read data files with Perl
What interface used in PERL to connect to database? How do you connect to database in Perl?
What does the qx{ } operator do?
How to implement a stack in Perl?
What is perl unshift array function?
what is perl language?
Explain perl. When do you use perl for programming?
Which guidelines by Perl modules must be followed?
Explain the meaning of perl one-liner?
What are the various perl data types based on the context?