Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

use vs require

by dash2 (Hermit)
on Feb 13, 2001 at 22:29 UTC ( [id://58181]=perlquestion: print w/replies, xml ) Need Help??

dash2 has asked for the wisdom of the Perl Monks concerning the following question:

Following on to a previous question I asked, I was wondering: what's the difference between "use" and "require"? I know how they work... no, wait - I think I know how they work - use happens in a little BEGIN block so it's done at compile time, while require happens at run time. But how much difference does this make? Is use twice as fast as require? 10 times? 1000 times? And what makes it faster anyway? Why should compiling something in earlier make it run faster?

Perlpexed,
Dave

Replies are listed 'Best First'.
Re: use vs require
by japhy (Canon) on Feb 13, 2001 at 22:36 UTC
    Actually, use is slower than require, because use also involves calling the import method.

    It's just that use happens earlier, so it only looks faster.

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://58181]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-19 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found