When my Perl projects are larger than a single script file, I usually create folders like this:
bin/ lib/ t/
You know what goes into what folder. And especially in the scripts which use your own modules you want to include something like this:
use lib '../lib';
This works fine when you call this script from your project root directory, but nowhere else. :(
rlib to the rescue!
use rlib '../lib';
This is equivalent to:
use FindBin; use lib "$FindBin::Bin/../lib";
Like "use lib" you can add more than one directory to @INC. If you specify no path at all, rlib uses "../lib" and "lib" as defaults. So, in our example we could have written "use rlib;" alone.
Links:
See also lib::abs for a little more modern version of the same basic functionality.
ReplyDelete