I've got into the habit of using File::ShareDir
along with the auto
directory tree. This is useful for storing any supplementary read-only files such as templates or data files.
- Deposit the data files in the corresponding auto directory in the Perl library path. For example reference files for lib/My/Module.pm are placed in directory lib/auto/My/Module.
- Use File::ShareDir to locate the file at run-time:
use warnings; use strict;
our $data_path = File::ShareDir::module_file(__PACKAGE__, 'mydata.yaml
By convention loaders and packagers look for and automatically include resources in auto
in the module path. So both will be packaged and installed together.