From: PerlFAQ Server on
This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

8.46: What's the difference between require and use?

(contributed by brian d foy)

Perl runs "require" statement at run-time. Once Perl loads, compiles,
and runs the file, it doesn't do anything else. The "use" statement is
the same as a "require" run at compile-time, but Perl also calls the
"import" method for the loaded package. These two are the same:

use MODULE qw(import list);

BEGIN {
require MODULE;
MODULE->import(import list);
}

However, you can suppress the "import" by using an explicit, empty
import list. Both of these still happen at compile-time:

use MODULE ();

BEGIN {
require MODULE;
}

Since "use" will also call the "import" method, the actual value for
"MODULE" must be a bareword. That is, "use" cannot load files by name,
although "require" can:

require "$ENV{HOME}/lib/Foo.pm"; # no @INC searching!

See the entry for "use" in perlfunc for more details.



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.