It does work very well though and I prefer it to fighting with
the MakeMaker docs to figure out how to get it to install a
data file in the right place :-)
Perl has language-level support for uuencoding/-decoding data
(check `perldoc -f pack`). You can take advantage of that to keep
your binary data way, way out of harm’s reach.
OK, stop right there before you scare the children.
This problem has been solved, and solved properly, while Audrey was
staying here in Lismore after YAPC::AU.
It's a two-part solution.
1. Put the shared files (content appropriate for /var/share) into a
"share" directory inside the root of your dist.
2. Use Module::Install for your installer (sorry, but the other two
don't support it yet). Add an install_share(); command to your Makefile.PL.
3. In your code, use the File::ShareDir module to locate the files
installed by your Makefile.PL.
Done!
It takes advantage of the same mechanism that is used by autosplit and
similar, so it works on every platform Perl supports, and it works on
every Perl back to something like Perl 4.
For a really good example of a "pure data" package with almost no
functionality in it, who's sole purpose is to provide data, and
implements the above, see:
http://search.cpan.org/~adamk/Lingua-EN-VarCon-0.01/lib/Lingua/EN/VarCon.pm
You can see in the source how File::ShareDir is used.
http://search.cpan.org/src/ADAMK/Lingua-EN-VarCon-0.01/lib/Lingua/EN/VarCon.pm
In the Makefile.PL how the share files are flagged for installation
http://search.cpan.org/src/ADAMK/Lingua-EN-VarCon-0.01/Makefile.PL
And in the dist where the files are.
http://search.cpan.org/src/ADAMK/Lingua-EN-VarCon-0.01/
OK? Good. I swear I'm going to shoot the next person I see install the
Arial Font as a 2.8megabyte Data::Dumper module.
And I'm happy to say Module::Install as of 0.61 is a LOT less flakey
than it's reputation has been in the past. It's not ready for common use
yet, but if you need shared data, then it's probably just the thing.
Unless someone wants to read how Module::Install::Share works and
implement a duplicate plugin/extension/whatever for Module::Build.
Adam K