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">
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:" />
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"> FindBin - Locate directory of original perl script
</span></strong></big>
17 <p><a name=
"__index__"></a></p>
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>
36 <h1><a name=
"name">NAME
</a></h1>
37 <p>FindBin - Locate directory of original perl script
</p>
41 <h1><a name=
"synopsis">SYNOPSIS
</a></h1>
44 use lib
"$FindBin::Bin/../lib
";
</pre>
49 use lib
"$Bin/../lib
";
</pre>
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><root
>/bin
</code> and
<code><root
>/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
66 <h1><a name=
"exportable_variables">EXPORTABLE VARIABLES
</a></h1>
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>
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>
86 FindBin::again(); # or FindBin-
>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>
90 delete $INC{'FindBin.pm'};
91 require FindBin;
</pre>
95 <h1><a name=
"known_bugs">KNOWN BUGS
</a></h1>
96 <p>If perl is invoked as
</p>
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>
105 perl ./filename
</pre>
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
<<em><a href=
"mailto:perlbug@perl.org">perlbug@perl.org
</a></em>> using the perlbug program
112 included with perl.
</p>
113 <p>Graham Barr
<<em><a href=
"mailto:gbarr@pobox.com">gbarr@pobox.com
</a></em>>
114 Nick Ing-Simmons
<<em><a href=
"mailto:nik@tiuk.ti.com">nik@tiuk.ti.com
</a></em>></p>
118 <h1><a name=
"copyright">COPYRIGHT
</a></h1>
119 <p>Copyright (c)
1995 Graham Barr
& 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"> FindBin - Locate directory of original perl script
</span></strong></big>