Miguel has asked for the wisdom of the Perl Monks concerning the following question:
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Including text files in Modules
by borisz (Canon) on Nov 04, 2004 at 17:57 UTC | |
by Miguel (Friar) on Nov 04, 2004 at 18:15 UTC | |
by Joost (Canon) on Nov 04, 2004 at 18:20 UTC | |
by Miguel (Friar) on Nov 04, 2004 at 19:34 UTC | |
Re: Including text files in Modules
by fglock (Vicar) on Nov 04, 2004 at 18:58 UTC | |
Re: Including text files in Modules
by Anonymous Monk on Nov 05, 2004 at 10:23 UTC | |
Re: Including text files in Modules
by tfrayner (Curate) on Nov 05, 2004 at 16:58 UTC |