Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / lib.html
blob445128fc35e37fcbaf1b4f0ff539a78bf3548563
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>lib - manipulate @INC at compile time</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;lib - manipulate @INC at compile time</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <ul>
27 <li><a href="#adding_directories_to__inc">Adding directories to @INC</a></li>
28 <li><a href="#deleting_directories_from__inc">Deleting directories from @INC</a></li>
29 <li><a href="#restoring_original__inc">Restoring original @INC</a></li>
30 </ul>
32 <li><a href="#caveats">CAVEATS</a></li>
33 <li><a href="#notes">NOTES</a></li>
34 <li><a href="#see_also">SEE ALSO</a></li>
35 <li><a href="#author">AUTHOR</a></li>
36 </ul>
37 <!-- INDEX END -->
39 <hr />
40 <p>
41 </p>
42 <h1><a name="name">NAME</a></h1>
43 <p>lib - manipulate @INC at compile time</p>
44 <p>
45 </p>
46 <hr />
47 <h1><a name="synopsis">SYNOPSIS</a></h1>
48 <pre>
49 use lib LIST;</pre>
50 <pre>
51 no lib LIST;</pre>
52 <p>
53 </p>
54 <hr />
55 <h1><a name="description">DESCRIPTION</a></h1>
56 <p>This is a small simple module which simplifies the manipulation of @INC
57 at compile time.</p>
58 <p>It is typically used to add extra directories to perl's search path so
59 that later <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_use"><code>use</code></a> or <a href="file://C|\msysgit\mingw\html/pod/perlfunc.html#item_require"><code>require</code></a> statements will find modules which are
60 not located on perl's default search path.</p>
61 <p>
62 </p>
63 <h2><a name="adding_directories_to__inc">Adding directories to @INC</a></h2>
64 <p>The parameters to <code>use lib</code> are added to the start of the perl search
65 path. Saying</p>
66 <pre>
67 use lib LIST;</pre>
68 <p>is <em>almost</em> the same as saying</p>
69 <pre>
70 BEGIN { unshift(@INC, LIST) }</pre>
71 <p>For each directory in LIST (called $dir here) the lib module also
72 checks to see if a directory called $dir/$archname/auto exists.
73 If so the $dir/$archname directory is assumed to be a corresponding
74 architecture specific directory and is added to @INC in front of $dir.</p>
75 <p>To avoid memory leaks, all trailing duplicate entries in @INC are
76 removed.</p>
77 <p>
78 </p>
79 <h2><a name="deleting_directories_from__inc">Deleting directories from @INC</a></h2>
80 <p>You should normally only add directories to @INC. If you need to
81 delete directories from @INC take care to only delete those which you
82 added yourself or which you are certain are not needed by other modules
83 in your script. Other modules may have added directories which they
84 need for correct operation.</p>
85 <p>The <code>no lib</code> statement deletes all instances of each named directory
86 from @INC.</p>
87 <p>For each directory in LIST (called $dir here) the lib module also
88 checks to see if a directory called $dir/$archname/auto exists.
89 If so the $dir/$archname directory is assumed to be a corresponding
90 architecture specific directory and is also deleted from @INC.</p>
91 <p>
92 </p>
93 <h2><a name="restoring_original__inc">Restoring original @INC</a></h2>
94 <p>When the lib module is first loaded it records the current value of @INC
95 in an array <code>@lib::ORIG_INC</code>. To restore @INC to that value you
96 can say</p>
97 <pre>
98 @INC = @lib::ORIG_INC;</pre>
99 <p>
100 </p>
101 <hr />
102 <h1><a name="caveats">CAVEATS</a></h1>
103 <p>In order to keep lib.pm small and simple, it only works with Unix
104 filepaths. This doesn't mean it only works on Unix, but non-Unix
105 users must first translate their file paths to Unix conventions.</p>
106 <pre>
107 # VMS users wanting to put [.stuff.moo] into
108 # their @INC would write
109 use lib 'stuff/moo';</pre>
111 </p>
112 <hr />
113 <h1><a name="notes">NOTES</a></h1>
114 <p>In the future, this module will likely use File::Spec for determining
115 paths, as it does now for Mac OS (where Unix-style or Mac-style paths
116 work, and Unix-style paths are converted properly to Mac-style paths
117 before being added to @INC).</p>
119 </p>
120 <hr />
121 <h1><a name="see_also">SEE ALSO</a></h1>
122 <p>FindBin - optional module which deals with paths relative to the source file.</p>
124 </p>
125 <hr />
126 <h1><a name="author">AUTHOR</a></h1>
127 <p>Tim Bunce, 2nd June 1995.</p>
128 <table border="0" width="100%" cellspacing="0" cellpadding="3">
129 <tr><td class="block" style="background-color: #cccccc" valign="middle">
130 <big><strong><span class="block">&nbsp;lib - manipulate @INC at compile time</span></strong></big>
131 </td></tr>
132 </table>
134 </body>
136 </html>