{
    "mode": "perldoc",
    "parameter": "FindBin",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/FindBin/json",
    "generated": "2026-06-15T16:42:35Z",
    "synopsis": "use FindBin;\nuse lib \"$FindBin::Bin/../lib\";\nor\nuse FindBin qw($Bin);\nuse lib \"$Bin/../lib\";",
    "sections": {
        "NAME": {
            "content": "FindBin - Locate directory of original perl script\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use FindBin;\nuse lib \"$FindBin::Bin/../lib\";\n\nor\n\nuse FindBin qw($Bin);\nuse lib \"$Bin/../lib\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Locates the full path to the script bin directory to allow the use of paths relative to the bin\ndirectory.\n\nThis allows a user to setup a directory tree for some software with directories \"<root>/bin\" and\n\"<root>/lib\", and then the above example will allow the use of modules in the lib directory\nwithout knowing where the software tree is installed.\n\nIf perl is invoked using the -e option or the perl script is read from \"STDIN\" then FindBin sets\nboth $Bin and $RealBin to the current directory.\n",
            "subsections": []
        },
        "EXPORTABLE VARIABLES": {
            "content": "$Bin         - path to bin directory from where script was invoked\n$Script      - basename of script from which perl was invoked\n$RealBin     - $Bin with all links resolved\n$RealScript  - $Script with all links resolved\n",
            "subsections": []
        },
        "KNOWN ISSUES": {
            "content": "If there are two modules using \"FindBin\" from different directories under the same interpreter,\nthis won't work. Since \"FindBin\" uses a \"BEGIN\" block, it'll be executed only once, and only the\nfirst caller will get it right. This is a problem under modperl and other persistent Perl\nenvironments, where you shouldn't use this module. Which also means that you should avoid using\n\"FindBin\" in modules that you plan to put on CPAN. To make sure that \"FindBin\" will work is to\ncall the \"again\" function:\n\nuse FindBin;\nFindBin::again(); # or FindBin->again;\n\nIn former versions of FindBin there was no \"again\" function. The workaround was to force the\n\"BEGIN\" block to be executed again:\n\ndelete $INC{'FindBin.pm'};\nrequire FindBin;\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "FindBin is supported as part of the core perl distribution. Please send bug reports to\n<perlbug@perl.org> using the perlbug program included with perl.\n\nGraham Barr <gbarr@pobox.com> Nick Ing-Simmons <nik@tiuk.ti.com>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved. This program is free\nsoftware; you can redistribute it and/or modify it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "FindBin - Locate directory of original perl script",
    "flags": [],
    "examples": [],
    "see_also": []
}