what is the difference between require and use in perl?

Answers were Sorted based on User's Feedback



what is the difference between require and use in perl?..

Answer / jayakumar.b

use:
* Object Verification will happen @ Compile Time.
* File will have extention of .pm
* Module location will be set by @ISA Variable.

require:
* Object Verification will happen @ Run TIme.
* Method can be used from and .pm or .pl file.
* Absolute path to be given, if file located in different
dir.

Is This Answer Correct ?    13 Yes 2 No

what is the difference between require and use in perl?..

Answer / rani

use:
1-its compile time concept & refresh the namespace for
different package loading.

Require:
it is run time concept & does not refresh the namespace for
different package loading.

Is This Answer Correct ?    4 Yes 0 No

what is the difference between require and use in perl?..

Answer / 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

More CGI Perl Interview Questions

my @array=('data1','data2'); my @array1=('data1','data2'); my ($i,$k); $i=7; $k=7; while($i){ $array [++$#array] = 'ree'; $i--; print "@array"; } while($k){ push(@array1,'ree'); $k--; print "@array1"; } Are these two while loop are doing the same functionality ? What may be the difference?

1 Answers   A1 Technology,


What is the Common Gateway Interface?

2 Answers  


What purpose does each of the following serve: -w, strict, - T ?

2 Answers  


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

0 Answers  


What is the difference between chop & chomp functions in perl?

10 Answers   Cap Gemini, DELL, Electronic Data, TCS,


Enlist the advantages of using c over perl?

0 Answers  


Explain splicing of arrays?

0 Answers  


What does next statement do in perl?

0 Answers  


Explain chomp?

0 Answers  


List the prefix dereferencer in Perl.

0 Answers  


What does -> symbol indicates in Perl?

0 Answers  


If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

0 Answers  


Categories