Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / FindBin.html
blob3eb9faa1f3341f57d25f1d525b24afd935688b82
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>FindBin - Locate directory of original perl script</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;FindBin - Locate directory of original perl script</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 <li><a href="#exportable_variables">EXPORTABLE VARIABLES</a></li>
26 <li><a href="#known_issues">KNOWN ISSUES</a></li>
27 <li><a href="#known_bugs">KNOWN BUGS</a></li>
28 <li><a href="#authors">AUTHORS</a></li>
29 <li><a href="#copyright">COPYRIGHT</a></li>
30 </ul>
31 <!-- INDEX END -->
33 <hr />
34 <p>
35 </p>
36 <h1><a name="name">NAME</a></h1>
37 <p>FindBin - Locate directory of original perl script</p>
38 <p>
39 </p>
40 <hr />
41 <h1><a name="synopsis">SYNOPSIS</a></h1>
42 <pre>
43 use FindBin;
44 use lib &quot;$FindBin::Bin/../lib&quot;;</pre>
45 <pre>
46 or</pre>
47 <pre>
48 use FindBin qw($Bin);
49 use lib &quot;$Bin/../lib&quot;;</pre>
50 <p>
51 </p>
52 <hr />
53 <h1><a name="description">DESCRIPTION</a></h1>
54 <p>Locates the full path to the script bin directory to allow the use
55 of paths relative to the bin directory.</p>
56 <p>This allows a user to setup a directory tree for some software with
57 directories <code>&lt;root&gt;/bin</code> and <code>&lt;root&gt;/lib</code>, and then the above
58 example will allow the use of modules in the lib directory without knowing
59 where the software tree is installed.</p>
60 <p>If perl is invoked using the <strong>-e</strong> option or the perl script is read from
61 <code>STDIN</code> then FindBin sets both <code>$Bin</code> and <code>$RealBin</code> to the current
62 directory.</p>
63 <p>
64 </p>
65 <hr />
66 <h1><a name="exportable_variables">EXPORTABLE VARIABLES</a></h1>
67 <pre>
68 $Bin - path to bin directory from where script was invoked
69 $Script - basename of script from which perl was invoked
70 $RealBin - $Bin with all links resolved
71 $RealScript - $Script with all links resolved</pre>
72 <p>
73 </p>
74 <hr />
75 <h1><a name="known_issues">KNOWN ISSUES</a></h1>
76 <p>If there are two modules using <code>FindBin</code> from different directories
77 under the same interpreter, this won't work. Since <code>FindBin</code> uses a
78 <code>BEGIN</code> block, it'll be executed only once, and only the first caller
79 will get it right. This is a problem under mod_perl and other persistent
80 Perl environments, where you shouldn't use this module. Which also means
81 that you should avoid using <code>FindBin</code> in modules that you plan to put
82 on CPAN. To make sure that <code>FindBin</code> will work is to call the <code>again</code>
83 function:</p>
84 <pre>
85 use FindBin;
86 FindBin::again(); # or FindBin-&gt;again;</pre>
87 <p>In former versions of FindBin there was no <code>again</code> function. The
88 workaround was to force the <code>BEGIN</code> block to be executed again:</p>
89 <pre>
90 delete $INC{'FindBin.pm'};
91 require FindBin;</pre>
92 <p>
93 </p>
94 <hr />
95 <h1><a name="known_bugs">KNOWN BUGS</a></h1>
96 <p>If perl is invoked as</p>
97 <pre>
98 perl filename</pre>
99 <p>and <em>filename</em> does not have executable rights and a program called
100 <em>filename</em> exists in the users <code>$ENV{PATH}</code> which satisfies both <strong>-x</strong>
101 and <strong>-T</strong> then FindBin assumes that it was invoked via the
102 <code>$ENV{PATH}</code>.</p>
103 <p>Workaround is to invoke perl as</p>
104 <pre>
105 perl ./filename</pre>
107 </p>
108 <hr />
109 <h1><a name="authors">AUTHORS</a></h1>
110 <p>FindBin is supported as part of the core perl distribution. Please send bug
111 reports to &lt;<em><a href="mailto:perlbug@perl.org">perlbug@perl.org</a></em>&gt; using the perlbug program
112 included with perl.</p>
113 <p>Graham Barr &lt;<em><a href="mailto:gbarr@pobox.com">gbarr@pobox.com</a></em>&gt;
114 Nick Ing-Simmons &lt;<em><a href="mailto:nik@tiuk.ti.com">nik@tiuk.ti.com</a></em>&gt;</p>
116 </p>
117 <hr />
118 <h1><a name="copyright">COPYRIGHT</a></h1>
119 <p>Copyright (c) 1995 Graham Barr &amp; Nick Ing-Simmons. All rights reserved.
120 This program is free software; you can redistribute it and/or modify it
121 under the same terms as Perl itself.</p>
122 <table border="0" width="100%" cellspacing="0" cellpadding="3">
123 <tr><td class="block" style="background-color: #cccccc" valign="middle">
124 <big><strong><span class="block">&nbsp;FindBin - Locate directory of original perl script</span></strong></big>
125 </td></tr>
126 </table>
128 </body>
130 </html>