what is the difference between require and use in perl?

Answer Posted / vinoth_bksys

The differences are many and often subtle:

* use only expects a bareword, require can take a
bareword or an expression
* use is evaluated at compile-time, require at run-time
* use implicitly calls the import method of the module
being loaded, require does not
* use excepts arguments in addition to the bareword (to
be passed to import), require does not
* use does not behave like a function (i.e can't be
called with parens, can't be used in an expression, etc),
whereas require does

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you access an element of a perl array?

520


What is perl dbi?

497


In Perl, what is grep function used for?

537


You want to read command-line arguements with perl. How would you do that?

502


Explain substr function in perl?

544






You want to empty an array. How would you do that?

480


What is the use of command “use strict”?

569


How many types of operators are used in the Perl?

585


Write syntax to use grep function?

552


Explain perl. When do you use perl for programming? What are the advantages of programming in perl?

471


How to start perl in interactive mode?

561


Explain gmtime() function in perl?

570


Where the command line arguments are stored and if you want to read command-line arguments with Perl, how would you do that?

690


What is the use of -n and -p options?

606


Difference between the variables in which chomp function work ?

612