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
Explain regular expression in perl?
Give an example of using the -n and -p option.
How to open and read data files with Perl
What are prefix dereferencer? List them.
Mention how many ways you can express string in Perl?
Explain goto label?
How to create a directory in perl?
Create a function that is only available inside the scope where it is defined ?
Is perl a case sensitive language?
Which has highest precedence in between list and terms? Explain?
What is a chop() function in perl?
How to read a directory in perl?
You want to concatenate strings with perl. How would you do that?
Can you add two arrays together?
How do I print the entire contents of an array with Perl?