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 do I replace every TAB character in a file with a comma?

735


What is the importance of perl warnings?

716


What does undef function in perl?

707


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

643


How to connect to SQL server through Perl?

751


How do you give functions private variables that retain their values between calls?

720


What is confess function in perl?

707


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

859


How to read multi lines from a file in perl?

683


What are the different string manipulation operators in perl?

700


Mention the difference between die and exit in Perl?

839


What are the advantages of perl programming?

746


How do I read command-line arguments with Perl?

783


How do find the length of an array?

729


Explain subroutine?

676