Last active
October 26, 2017 13:37
-
-
Save leingang/c49cbf37100ecbb6e2f58ca7761ef712 to your computer and use it in GitHub Desktop.
How to change @inc to point to a relative directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use File::Basename qw(dirname); | |
use FindBin qw($Bin); | |
use lib dirname($Bin) . '/lib'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See How to create a Perl Module for code reuse? by Gabor Szabo, in particular the first comment by Nigel Peck.
Say you have a perl project with executables in
bin/
and modules inlib/
. How do you get the executables to locate the modules?dirname
function from File::Basename, which does what you think it does.bin
; it's just the name of the including directory. This directory name is stored in$Bin
.$Bin
, attaches/lib
, and appends this to@INC
. In other words, the sister directory to$Bin
namedlib
.