Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Including periodically changing data with modules

by snoopy (Deacon)
on Jul 10, 2008 at 07:47 UTC ( #696634=note: print w/replies, xml ) Need Help??

in reply to Including periodically changing data with modules

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.
  1. Deposit the data files in the corresponding auto directory in the Perl library path. For example reference files for lib/My/ are placed in directory lib/auto/My/Module.
  2. Use File::ShareDir to locate the file at run-time:
package My::Module; use warnings; use strict; use File::ShareDir; 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.

Replies are listed 'Best First'.
Re^2: Including periodically changing data with modules
by EvanCarroll (Chaplain) on Jul 10, 2008 at 10:08 UTC
    This didn't work for me at all, I'm finding this module to be more trouble than it is worth. Good idea, horrible docs and only slightly less complex than the task itself.
    This nonsensery comes in two components, neither makes sense. One of them wants your stuff to be in ./lib/auto, (the loader), while the installer wants it to be in ./share. Use both of the defaults, and "make test" won't work. It moves the files to ./blib/lib/auto, but it doesn't set up the testing environment to use it I suppose. The loader isn't of much help either, cloaking the full location of the failed open -- or whatever it is failing at.
    t/date_misc_b...........File 'y/XLang/English.yaml' does not exist in +module dir at Date-Manip-5.54/blib/lib/Date/ line 353
    I mean come on, where the fuck is the module dir. I've tried setting it to the module name (__PACKAGE__) and giving it the dist-name, neither work. It works outside using a "prove -l ./t/*.t"

    # Compile-testing for PITA::Report use lib (); use File::Spec::Functions ':ALL'; BEGIN { $| = 1; unless ( $ENV{HARNESS_ACTIVE} ) { require FindBin; $FindBin::Bin = $FindBin::Bin; # Avoid a warning chdir catdir( $FindBin::Bin, updir() ); lib->import( catdir('blib', 'lib'), catdir('blib', 'arch'), 'lib', ); }

    So you have to code like that above every test script? eww.

    really this module just needs some non-shitty docs, it isn't half bad

    Evan Carroll
    I hack for the ladies.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://696634]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-03-24 06:26 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.