{
    "mode": "perldoc",
    "parameter": "lib",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/lib/json",
    "generated": "2026-06-13T22:56:14Z",
    "synopsis": "use lib LIST;\nno lib LIST;",
    "sections": {
        "NAME": {
            "content": "lib - manipulate @INC at compile time\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use lib LIST;\n\nno lib LIST;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a small simple module which simplifies the manipulation of @INC at compile time.\n\nIt is typically used to add extra directories to perl's search path so that later \"use\" or\n\"require\" statements will find modules which are not located on perl's default search path.\n\nAdding directories to @INC\nThe parameters to \"use lib\" are added to the start of the perl search path. Saying\n\nuse lib LIST;\n\nis *almost* the same as saying\n\nBEGIN { unshift(@INC, LIST) }\n\nFor each directory in LIST (called $dir here) the lib module also checks to see if a directory\ncalled $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a\ncorresponding architecture specific directory and is added to @INC in front of $dir. lib.pm also\nchecks if directories called $dir/$version and $dir/$version/$archname exist and adds these\ndirectories to @INC.\n\nThe current value of $archname can be found with this command:\n\nperl -V:archname\n\nThe corresponding command to get the current value of $version is:\n\nperl -V:version\n\nTo avoid memory leaks, all trailing duplicate entries in @INC are removed.\n\nDeleting directories from @INC\nYou should normally only add directories to @INC. If you need to delete directories from @INC\ntake care to only delete those which you added yourself or which you are certain are not needed\nby other modules in your script. Other modules may have added directories which they need for\ncorrect operation.\n\nThe \"no lib\" statement deletes all instances of each named directory from @INC.\n\nFor each directory in LIST (called $dir here) the lib module also checks to see if a directory\ncalled $dir/$archname/auto exists. If so the $dir/$archname directory is assumed to be a\ncorresponding architecture specific directory and is also deleted from @INC. lib.pm also checks\nif directories called $dir/$version and $dir/$version/$archname exist and deletes these\ndirectories from @INC.\n\nRestoring original @INC\nWhen the lib module is first loaded it records the current value of @INC in an array\n@lib::ORIGINC. To restore @INC to that value you can say\n\n@INC = @lib::ORIGINC;\n",
            "subsections": []
        },
        "CAVEATS": {
            "content": "In order to keep lib.pm small and simple, it only works with Unix filepaths. This doesn't mean\nit only works on Unix, but non-Unix users must first translate their file paths to Unix\nconventions.\n\n# VMS users wanting to put [.stuff.moo] into\n# their @INC would write\nuse lib 'stuff/moo';\n",
            "subsections": []
        },
        "NOTES": {
            "content": "In the future, this module will likely use File::Spec for determining paths, as it does now for\nMac OS (where Unix-style or Mac-style paths work, and Unix-style paths are converted properly to\nMac-style paths before being added to @INC).\n\nIf you try to add a file to @INC as follows:\n\nuse lib 'thisisafile.txt';\n\n\"lib\" will warn about this. The sole exceptions are files with the \".par\" extension which are\nintended to be used as libraries.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "FindBin - optional module which deals with paths relative to the source file.\n\nPAR - optional module which can treat \".par\" files as Perl libraries.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Tim Bunce, 2nd June 1995.\n\n\"lib\" is maintained by the perl5-porters. Please direct any questions to the canonical mailing\nlist. Anything that is applicable to the CPAN release can be sent to its maintainer, though.\n\nMaintainer: The Perl5-Porters <perl5-porters@perl.org>\n\nMaintainer of the CPAN release: Steffen Mueller <smueller@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This package has been part of the perl core since perl 5.001. It has been released separately to\nCPAN so older installations can benefit from bug fixes.\n\nThis package has the same copyright and license as the perl core.\n",
            "subsections": []
        }
    },
    "summary": "lib - manipulate @INC at compile time",
    "flags": [],
    "examples": [],
    "see_also": []
}