Acme::Include::Data - how to include data files with a CPAN module


This is a demonstration module which exists for the purpose of examining its source code rather than for use.


This documents Acme::Include::Data version 0.05 corresponding to git commit 888db01e4ebcd8509cf550a8be559e728425126b released on Thu Feb 2 09:04:20 2017 +0900.


This is a demonstration module which demonstrates how to include a data file with a Perl module and how to read it in at run time.

If you are a CPAN author or use the CPAN-style tools to distribute your data, you may have wondered how to include data with your Perl distribution.

Any file under lib in the distribution is bundled into the distribution by Makefile.PL. So if your distribution is called Acme::Include::Data, then a file called lib/Acme/Include/this-is-a-data-file.txt is automatically included into the distribution.

To read the data file in, simply use __FILE__:

    my $data = __FILE__;
    # Make whatever substitutions are necessary:
    $data =~ s/Data\.pm$/this-is-a-data-file.txt/;
    # Read the data in:
    open my $in, "<", $data or die $!;
    my $text = '';
    while (<$in>) {
        $text .= $_;

(This example is included as in the distribution.)



This is a function for testing the module.


Please see this blog post for more explanation.


Ben Bullock, <>


This package and associated files are copyright (C) 2014-2017 Ben Bullock.

You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.