Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Difference between 'use' and 'require'

by broquaint (Abbot)
on Dec 07, 2004 at 09:57 UTC ( #412870=note: print w/ replies, xml ) Need Help??


in reply to Difference between 'use' and 'require'

The differences are many and often subtle:

  • use only expects a bareword, require can take a bareword or an expression
  • use is evaluated at compile-time, require at run-time
  • use implicitly calls the import method of the module being loaded, require does not
  • use excepts arguments in addition to the bareword (to be passed to import), require does not
  • use does not behave like a function (i.e can't be called with parens, can't be used in an expression, etc), whereas require does
So they behave differently but achieve the same goal. Then there's a list of cultural differences in addition to the technical differences, but they're not so hard and fast.
HTH

_________
broquaint


Comment on Re: Difference between 'use' and 'require'
Re^2: Difference between 'use' and 'require'
by ikegami (Pope) on Dec 07, 2004 at 15:01 UTC
    use implicitly calls the import method of the module being loaded, require does not

    That's optional. Adding empty parens (as in use Socket ();) prevents import from being called.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://412870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-08-21 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls