简体   繁体   中英

How to split perl programm over multiple files

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).

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM