use or require?

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

Can any one explain?

Thanks.
mwhuenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
tpajithCommented:

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.