I have a dir called foo, and in that I have lib and bin. The scripts in bin need stuff in lib. I do something like this:
foo
lib
bin
#!perl use strict; use warnings; use lib '../lib'; use Foo; # <-- comes from lib
But that means I have to be in the bin dir to run the script. Surely there is a better way. What's the Right Way to do this?
The standard FindBin module does what you want.
FindBin
use FindBin; use lib "$FindBin::Bin/../lib";
perldoc FindBin for more.
perldoc FindBin
1.4m articles
1.4m replys
5 comments
57.0k users