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 CPAN?
Write syntax to use grep function?
Define dynamic scoping.
What is the difference between use and require in perl?
Why -w argument is used with perl programs?
What is “grep” function in perl?
Write syntax to add two arrays together in perl?
How to renaming a file in perl programming?
Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.
Explain perl. When do you use perl for programming?
how to create a flat file database as shown below s.no name age city phone 0 hema 22 Calcutta 4312542 1 hema 21 Bangalore 2344345 2 ganesh 25 delhi 2445454 3 kartik 45 pune 4312121 4 santosh 25 Hyderabad 2254231 5 kumar 25 mysore 2344567 6 gita 34 mangalore 6532123 7 gita 32 pune 2213456 Q1.print the details of the person who r from bangalore q2.Replace the city name managlore to pune q3.prints no of person having name gita and hema q4.print how many are of age 25.
How will you declare a variable in perl?
What is a chop() function in perl?
What are hashes?
What are the various file operations in perl. Explain with example.