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
Which operator in perl is used for the concatenation of two strings?
What syntax is used for grep() function?
Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.
How do I replace every character in a file with a comma?
what is Polymorphism in Perl?
What are the advantages of programming in perl?
How to determine strings length in perl?
How to copy a file in perl?
How do you turn on the perl warnings?
There are two types of eval statements i.e. Eval expr and eval block. Explain them.
How many types of variable in perl?
What is a chop() function in perl?
what is Chop & Chomp function does?
How to access parameters passed to a subroutine in perl?
What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?