Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How do I include a file?

by ariels (Curate)
on May 22, 2002 at 12:55 UTC ( [id://168416]=note: print w/replies, xml ) Need Help??


in reply to How do I include a file?

Notes on 2 of the above answers:
  • A Perl programmer who doesn't want to create <samp>EXPORT</samp> lists will use the simpler form
    use Module ();

    Also, note the subtle differences between require "Name" and require Name...

  • There's a difference between use and require (on the one hand) and do (on the other).

    <samp>do</samp> essentially reads and evals the file; like any <samp>eval</samp>, it returns the value calculated. This value may be logically true, or it may not be; it doesn't matter.

    <samp>require</samp> (and therefore <samp>use</samp> too) attempts to ensure some semantics are loaded. This might fail! So a required (or used) module is required (sorry) to return logical true if successful, or logical false if not. Thus the need to end those files with "1;" (or any other truth!). It's not needed if just <samp>do</samp>ing something (e.g. if loading a configuration file (unsafely)).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-16 13:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found