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


Please Help Members By Posting Answers For Below Questions

what is CPAN?

718


Write syntax to use grep function?

737


Define dynamic scoping.

665


What is the difference between use and require in perl?

660


Why -w argument is used with perl programs?

740


What is “grep” function in perl?

758


Write syntax to add two arrays together in perl?

714


How to renaming a file in perl programming?

756


Write a program to download the contents from www.perlinterview.com/answers.php website in Perl.

711


Explain perl. When do you use perl for programming?

642


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.

1854


How will you declare a variable in perl?

744


What is a chop() function in perl?

780


What are hashes?

722


What are the various file operations in perl. Explain with example.

714