Explain the difference between use and require?

Answer Posted / gopi sreekanth

use can take a bareword and require doesnot while accessing
module
use is used in compile time ie all code is parsed before
program run where as require is used in run time. So if
there is much code in initialization include that in use
rather than require
use supports import method by default and require doesnt
support
Inside use default import method will be present. BEGIN {
require Module; }

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Who created perl?

720


Suppose an array contains @arraycontent=(‘ab’, ‘cd’, ‘ef’, ‘gh’). How to print all the contents of the given array?

794


Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

738


Explain perl. What are the advantages of programming in perl?

819


How to remove a directory in perl?

720


How do I debug a perl program?

748


Explain 'grep' function.

800


What is the use of '>>' in perl?

754


What is cpan in perl?

743


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

688


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

667


What is qq (double q)operator in perl?

803


Explain the execution of a program in perl.

732


What does a die() function do in perl?

789


What are prefix dereferencer? List them.

775