1FindBin(3pm)           Perl Programmers Reference Guide           FindBin(3pm)
2
3
4

NAME

6       FindBin - Locate directory of original perl script
7

SYNOPSIS

9        use FindBin;
10        use lib "$FindBin::Bin/../lib";
11
12        or
13
14        use FindBin qw($Bin);
15        use lib "$Bin/../lib";
16

DESCRIPTION

18       Locates the full path to the script bin directory to allow the use of
19       paths relative to the bin directory.
20
21       This allows a user to setup a directory tree for some software with
22       directories "<root>/bin" and "<root>/lib", and then the above example
23       will allow the use of modules in the lib directory without knowing
24       where the software tree is installed.
25
26       If perl is invoked using the -e option or the perl script is read from
27       "STDIN" then FindBin sets both $Bin and $RealBin to the current direc‐
28       tory.
29

EXPORTABLE VARIABLES

31        $Bin         - path to bin directory from where script was invoked
32        $Script      - basename of script from which perl was invoked
33        $RealBin     - $Bin with all links resolved
34        $RealScript  - $Script with all links resolved
35

KNOWN ISSUES

37       If there are two modules using "FindBin" from different directories
38       under the same interpreter, this won't work. Since "FindBin" uses a
39       "BEGIN" block, it'll be executed only once, and only the first caller
40       will get it right. This is a problem under mod_perl and other persis‐
41       tent Perl environments, where you shouldn't use this module. Which also
42       means that you should avoid using "FindBin" in modules that you plan to
43       put on CPAN. To make sure that "FindBin" will work is to call the
44       "again" function:
45
46         use FindBin;
47         FindBin::again(); # or FindBin->again;
48
49       In former versions of FindBin there was no "again" function. The work‐
50       around was to force the "BEGIN" block to be executed again:
51
52         delete $INC{'FindBin.pm'};
53         require FindBin;
54

KNOWN BUGS

56       If perl is invoked as
57
58          perl filename
59
60       and filename does not have executable rights and a program called file‐
61       name exists in the users $ENV{PATH} which satisfies both -x and -T then
62       FindBin assumes that it was invoked via the $ENV{PATH}.
63
64       Workaround is to invoke perl as
65
66        perl ./filename
67

AUTHORS

69       FindBin is supported as part of the core perl distribution. Please send
70       bug reports to <perlbug@perl.org> using the perlbug program included
71       with perl.
72
73       Graham Barr <gbarr@pobox.com> Nick Ing-Simmons <nik@tiuk.ti.com>
74
76       Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
77       This program is free software; you can redistribute it and/or modify it
78       under the same terms as Perl itself.
79
80
81
82perl v5.8.8                       2001-09-21                      FindBin(3pm)
Impressum