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
28       directory.
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
41       persistent Perl environments, where you shouldn't use this module.
42       Which also means that you should avoid using "FindBin" in modules that
43       you plan to put on CPAN. To make sure that "FindBin" will work is to
44       call the "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
50       workaround was to force the "BEGIN" block to be executed again:
51
52         delete $INC{'FindBin.pm'};
53         require FindBin;
54

AUTHORS

56       FindBin is supported as part of the core perl distribution. Please send
57       bug reports to <perlbug@perl.org> using the perlbug program included
58       with perl.
59
60       Graham Barr <gbarr@pobox.com> Nick Ing-Simmons <nik@tiuk.ti.com>
61
63       Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
64       This program is free software; you can redistribute it and/or modify it
65       under the same terms as Perl itself.
66
67
68
69perl v5.34.0                      2021-10-18                      FindBin(3pm)
Impressum