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

Data files in Perl module distributions?

by cdybedahl (Acolyte)
on Apr 13, 2012 at 12:40 UTC ( #964914=perlquestion: print w/ replies, xml ) Need Help??
cdybedahl has asked for the wisdom of the Perl Monks concerning the following question:

Hello there.

I'm maintaining a Perl module. To work properly, it needs a couple of data files (in YAML format). Currently, they get installed by ExtUtils::MakeMaker in a disgustingly hacky way, and later located by the Perl code by looking up a starting point in Config.pm. This works, but it is ugly. It's also somewhat problematic when it comes to some Perl installation variants (particularly, for me right now, Debian's).

So I've been trying to find out what's the right and proper way of including data files with Perl modules, on the assumption that I cannot possibly be the first person ever to need that. And I can't find anything about this. Not in the Perl documentation, not in the MakeMaker documentation, not in the Module::Install documentation, not with Google, not... just not.

Does anyone here know anything about this? Any hints on other modules that have data files? Documentation I've missed?

Comment on Data files in Perl module distributions?
Re: Data files in Perl module distributions?
by Anonymous Monk on Apr 13, 2012 at 12:47 UTC
Re: Data files in Perl module distributions?
by moritz (Cardinal) on Apr 13, 2012 at 12:48 UTC
Re: Data files in Perl module distributions?
by SBECK (Pilgrim) on Apr 13, 2012 at 14:47 UTC
    I usually do this by just storing the YAML in a perl module. So I have:
    package My::Package::Data1; use YAML::Syck; my @in = <DATA>; $Data = Load(join('',@in)); __DATA__ --- key: val key: val ...
    If the YAML files are really complicated, or generated from something else, or used in a non-perl context, this might not be ideal, but if they're strictly internal to the perl module, I like this since it avoids all of the complexities of handling data files on the myriad of architectures and installation setups that it might be used on.
Re: Data files in Perl module distributions?
by zengargoyle (Deacon) on Apr 14, 2012 at 06:14 UTC

    Though be warned File::ShareDir only works for architecture independent files.

    If you have some architecture dependent blob it should go in (for example) lib/site_perl/5.14.2/x86_64-linux/auto/share/dist/Dist-Name and not lib/site_perl/5.14.2/auto/share/dist/Dist-Name.

    Sadly some modules miss this distinction. I'm not sure if there are modules to help with this case.

      Though be warned File::ShareDir only works for architecture independent files.... Sadly some modules miss this distinction. I'm not sure if there are modules to help with this case.

      Um, like who?

        Alien::Tidyp
        /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/bin/tidyp /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/include/tidyp /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/include/tidyp/buffio.h /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/include/tidyp/platform.h /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/include/tidyp/tidyp.h /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/include/tidyp/tidypenum.h /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/lib/libtidyp.a /var/local/perl/5.14.2/lib/site_perl/5.14.2/auto/share/dist/Alien-Tidy +p/v1.4.7/lib/libtidyp.la
        Alien::Base - Still beta-ish but I filed an issue and got a sorta "meh, not in scope of project" response. I've run into the problem somewhere else but I forget where (probably just installed the needed external dependency).

        I guess I'm just weird for keeping 4 architectures in the same Perl tree, and I might try to fork and fix sometime in the future. Warning applies for anything that stores a binary or library or binary data (endianness) using the File::ShareDir pattern.

        Just bringing it up so people think about what they put where.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964914]
Approved by marto
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-12-25 01:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls