Esteemed Monks,

Is there any simple and practical way to include txt files in a module?

This is my problem:

I have a package named Foo::Foo1::Foo2::FooPackageName This reads 3 text files (data sources)

my @files = qw/file1 file2 file3/; foreach my $file (@files) { open( INFILE, '<', './lib/Foo/Foo1/Foo2/' . $file . ".txt" ) or die "$0 : ERROR : could not open file '" . $file . ".txt' : $!\n"; [CODE HERE] }

Now, when I do a perl Makefile.PL, make, make test and make install everything runs fine. (The MANIFEST also includes those 3 files)

Then, I can see the files in the right directory (/usr/lib/etc...)

But, when I try to run some program using that module it complains about not getting the files.

What am I doing wrong or missing here?

---------------- UPDATE -----

Maybe I wasn't clear enough before.
Let me put it this way:

Q1. Is it possible to include txt files (as data sources) inside a Perl package? (not to dump the contents as some kind of variables; the idea is to keep those files intact)

Q2. How do I do that in a portable way? this is, no matter what system is running the module, those files are always accessible (probably in the same directory where the module is)

------------------ UPDATE -----

Miguel


In reply to Including text files in Modules by Miguel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.