use or require?

what is the difference of use and require?
use lib? push?

Can any one explain?

Thanks.
mwhuenAsked:
Who is Participating?
 
tpajithConnect With a Mentor Commented:

Both use and require functions of PERL are used to include a perl module inside your present working program.The difference being that, if you what to include a perl builtin module in your program and use all the functions and properties of that object, you can use the USE function.
eq.
The CGI module.
You can use the CGI module available in your program like..

use CGI;
#create an instance of that.
$q = new CGI;
#now u can use all the methods through #the $q instance.
print $q->header(-type => 'text/html');
print $q->start_html();
print $q->end_html();

The require function is used to include user written perl modules available in your present program.ie, you can write many functions in a perl program and make all the functions available to any of your programs just by including..

require "function_perl.pl"

with regards,
ajith.
0
 
ozoCommented:
perldoc -f use
perldoc -f require
perldoc lib
perldoc -f push
0
 
maneshrCommented:
* use Module

Imports some semantics into the current package from the
named module, generally by aliasing certain subroutine
or variable names into your package. It is exactly
equivalent to

BEGIN { require Module; import Module LIST; }


* require file

Demands that a library file be included if it hasn't already been included.

* use lib

This is a small simple module which simplifies the manipulation of @INC at compile time.

It is typically used to add extra directories to perl's search path so that later `use' or `require' statements will find modules which are not located on perl's default search path.


*  push ARRAY,LIST

Treats ARRAY as a stack, and pushes the values of LIST onto the end of ARRAY. The length of ARRAY increases by the length of LIST. Has the same effect as

for $value (LIST) {
  $ARRAY[++$#ARRAY] = $value;
}

but is more efficient. Returns the new number of elements in the array.
0
All Courses

From novice to tech pro — start learning today.