perlfunc
root
<P>
FindBin - Locate directory of original perl script
<P>
<HR>
<P>
<PRE> use FindBin;
use lib "$FindBin::Bin/../lib";
</PRE>
<P>
<PRE> or
</PRE>
<P>
<PRE> use FindBin qw($Bin);
use lib "$Bin/../lib";
</PRE>
<P>
<HR>
<P>
Locates the full path to the script bin directory to allow the use of paths
relative to the bin directory.
<P>
This allows a user to setup a directory tree for some software with
directories <root>/bin and <root>/lib and then the above
example will allow the use of modules in the lib directory without knowing
where the software tree is installed.
<P>
If perl is invoked using the <STRONG>-e</STRONG> option or the perl script is read from
<CODE>STDIN</CODE> then FindBin sets both <CODE>$Bin</CODE> and <CODE>$RealBin</CODE> to the current directory.
<P>
<HR>
<H1><A NAME="EXPORTABLE_VARIABLES">EXPORTABLE VARIABLES</A></H1>
<P>
<PRE> $Bin - path to bin directory from where script was invoked
$Script - basename of script from which perl was invoked
$RealBin - $Bin with all links resolved
$RealScript - $Script with all links resolved
</PRE>
<P>
<HR>
<H1><A NAME="KNOWN_BUGS">KNOWN BUGS</A></H1>
<P>
if perl is invoked as
<P>
<PRE> perl filename
</PRE>
<P>
and <EM>filename</EM> does not have executable rights and a program called <EM>filename</EM>
exists in the users <CODE>$ENV{PATH}</CODE> which satisfies both <STRONG>-x</STRONG> and <STRONG>-T</STRONG> then FindBin assumes that it was invoked via the <CODE>$ENV{PATH}</CODE>.
<P>
Workaround is to invoke perl as
<P>
<PRE> perl ./filename
</PRE>
<P>
<HR>
<H1><A NAME="AUTHORS">AUTHORS</A></H1>
<P>
Graham Barr <<EM>bodg@tiuk.ti.com</EM>> Nick Ing-Simmons <<EM>nik@tiuk.ti.com</EM>>
<P>
<HR>
<H1><A NAME="COPYRIGHT">COPYRIGHT</A></H1>
<P>
Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
<P>
<HR>
<H1><A NAME="REVISION">REVISION</A></H1>
<P>
$Revision: 1.4 $
<HR>