I am going to paste an email Alan Stewart sent me after I asked how to add a
text file.  I will include my question and his answer.   I have not tried it
yet.  Hope it helps.

On 5 May 2004 at 16:30, the.noonings wrote:

>
> Hello Alan,
>
> With the web site and email problems Autrijus is having, I don't want to
bother him for a few
> days. Hence this message to you.
>
> I want to take a large file my_data.txt and include it into my finished
executable. The -I and -M
> flags seem to work only with .pm modules that are called in with "use" or
"require" within the
> invoking perl script itself. I could make a .pm file out of the text file,
and then "use" it, but that
> would mean a huge memory expenditure every time the executable is clicked
on.
>
> My script is written such that the my_data.txt file is opened, and the
areadly known line number is
> skipped to, one line at a time. The data at that line iswhat is returned.
The file is then closed
> out. The line number can be anything, from 0 to millions. Hence the need
to process the file one
> line at a time.
>
> Any ideas?
>
> Thanks
>

How about this?
##################################

C:\a\9>type t5.pl
use PAR;
use Archive::Zip::MemberRead;

$fh  = new Archive::Zip::MemberRead($PAR::LibCache{$0}, "my_data.txt");
while (defined($line = $fh->getline()))
{
    print $fh->input_line_number . "#: $line\n";
}

print "$0 Done\n";
C:\a\9>copy t5.pl my_data.txt
        1 file(s) copied.

C:\a\9>pp -M c:\a\9\my_data.txt -o t5.exe t5.pl

C:\a\9>t5.exe
1#: use PAR;
2#: use Archive::Zip::MemberRead;
3#:
4#: $fh  = new Archive::Zip::MemberRead($PAR::LibCache{$0}, "my_data.txt");
5#: while (defined($line = $fh->getline()))
6#: {
7#:     print $fh->input_line_number . "#: $line\n";
8#: }
9#:
10#: print "$0 Done\n";
t5.exe Done

C:\a\9>
##################################

%PAR::LibCache contains a zip handle for each PAR loaded and the PAR in the
executable
is there automatically, with the key equal to the executable filename. Since
it's a zip
handle, you can use any of the Archive::Zip functions on it.

Archive::Zip::MemberRead give you line by line reading direct from the zip
file and
there is also a rewind function there.

The -M option to pp will add any file with a path name to the root of the
zip file
(minus path).

Alan Stewart


----- Original Message ----- 
From: "Vlad Harchev" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 07, 2004 6:04 AM
Subject: any way to add arbitrary files to PAR (e.g. graphic or text files)?


> Hello,
>
> What is the official way of adding arbitrary files (not perl source - e.g.
> mylogo.png) to PAR files?
>
> Obviuosly PAR files are zip files - but how one can add files to PAR file
so
> that they will be handled correctly at runtime (i.e. extracted along other
> files, ect)?
>
> I think it will greatly help if there was some 'pp' option to add
arbitrary
> files to the PAR/binary.
> -- 
>  Best regards,
>   -Vlad
>

Reply via email to