How do I use functionality written in a different file, but not located in an @INC
location, but relative to the main executable? I want to be able to distribute the entire directory and have it be executable everywhere (assuming third-party libraries are already installed).
CodePudding user response:
You can use FindBin to get the location of your main executable and lib to add directories to your @INC
that are based on your main directory.
A common example would be if your libraries were in a /lib
directory below the directory that contains your main program.
use FindBin '$RealBin';
use lib "$RealBin/lib";
# You can then load your own modules from /lib
use My::Module;