On Wed, 28 Dec 2005, Octavian Rasnita wrote:
> I have tried to store some data in a perl program under the
>
> __DATA__
>
> mark, then to read from there using:
>
> while(<DATA>) {
> ...
> }
>
> The program works when I run it as a .pl file, but if I create a .exe file
> using perlapp, it doesn't read anything from <DATA>.
>
> Is there something I can do to make it work?
This is supposed to work. I just tested it with this little test program, and
it seemed to work fine:
use strict;
use warnings;
print "start\n";
while (<DATA>) {
chomp;
print "data: $_\n";
}
print "done\n";
__DATA__
one
two
three
I've been using ActivePerl build 815 and PerlApp 6.0.2 for this test.
Can you send me a small sample program in which the DATA filehandle doesn't
work?
> I cannot put the data in a big array, because it is too much data (over 7
> mb) and the program works very slow in that case.
>
> Or is there other way of using a separate file which is included in the .exe
> program, but it is not stored as a .txt file?
You can use the --bind option to bundle additional data with your executable.
Then use the PerlApp::get_bound_file() function to read this data at runtime.
See `perlapp --help get_bound_file` for a sample.
Cheers,
-Jan