chanklaus has asked for the wisdom of the Perl Monks concerning the following question:

Dear sisters and brothers in Perl,

I wrote a Perl/Tk application for a Windows OS. When it starts it displays a bitmap file which is located in the same directory as the Perl script is.

Now, I want to make the program available for others, who not necessarily have a Perl installed on their system. Solution obviously is to pack the program into an executable PAR archive with the PAR::Packer "pp" program. The bitmap file is missing then, but it can be packed into the archive with the --addfile option. However, my program won't find the bitmap when started - I assume that it can't because the archive is unpacked in another directory than the executable file is located, but the current path is the one where the executable is placed - which I tested with the cwd command.

I tried to find a solution with Google, but either I asked the wrong keywords, or I simply am too stupid - or both. That's why I would like to ask you for help.

My question is either:
How do I locate the bitmap file which I added to the archive using the --addfile option?
or
Which other possibility do I have to include the bitmap into my program?

Many thanks in advance.

Best greetings and wishes,
Yours

chanklaus

Learning is like swimming against the current - as soon as you stop you'll drift back
(Chinese proverb)
  • Comment on PAR::Packer: pp with addfile option: where are the files?

Replies are listed 'Best First'.
Re: PAR::Packer: pp with addfile option: where are the files?
by Marshall (Canon) on Nov 07, 2009 at 17:47 UTC
    I use the Active State tools, but do have the same situation with icon files, etc that are used by but are not part of the .exe file. I just make a .zip file with the .ini,.bmp,.exe file etc. Simple and works fine for me.

    Update: not sure if you mean the icon that Windows displays for the .exe? With activestate there is an option for me to specify that icon. I don't know how to do that with pp. sorry. I think there is some Windows shell stuff that can do that if icon is a separate file, but I've forgotten how to do it. Anyway once the program is going, Tk can find it if .bmp file in same dir as the .exe. Google on "Windows embed icon" and there are some things that might be useful to you. You may have to embed it so that windows can display for the .exe and also include the file in .zip for your Tk application to use it.

Re: PAR::Packer: pp with addfile option: where are the files?
by AnomalousMonk (Archbishop) on Nov 07, 2009 at 19:28 UTC
    Both Tk::Bitmap and Tk::Pixmap allow the image to be specified as a data string within the program itself using the  -data =>string option. As no separate file is needed, this approach may be helpful to you.
Re: PAR::Packer: pp with addfile option: where are the files?
by Anonymous Monk on Nov 07, 2009 at 19:08 UTC
Re: PAR::Packer: pp with addfile option: where are the files?
by chanklaus (Acolyte) on Nov 08, 2009 at 10:37 UTC

    The solution with the Tk::Bitmap and the Tk::Pixmap is great and definitively woth a try.

    However, still it would be good to know how to find out where the "addfiles" go. Somehow, when the executable Perl archive is started, it has to know where to extract the archive. Who - or rather what - tells the executable in which directory to extract? And when the files are extracted the (also extracted) Perl interpreter has to know the file and path name of the perl source code file. Anyhow: why should it be possible to add files when I can't find them anymore?

    It would be beneficial to know the extraction path, then I can construct eg. installation scripts: pack the files which are to be installed in the archive, together with the Perl script, just start the executable - and it installs the files wherever or however they are meant to be installed.

    I assume that it should be a system variable of the Windows OS - but which one, and how to capture?

    Anybody who knows how to find out the path information from the running Perl program?

    Best greetings and wishes,
    Yours
    chanklaus

    Learning is like swimming against the current - as soon as you stop you'll drift back
    (Chinese proverb)
Re: PAR::Packer: pp with addfile option: where are the files?
by chanklaus (Acolyte) on Nov 11, 2009 at 09:07 UTC

    AnonymousMonk: I apologize. I got confused by the HTML and pod things and have mistaken your post as erraneously gone into my thread.

    For all those who might be interested in this matter: the variable I was looking for is
    $ENV{'PAR_TEMP'} and with
    use PAR; ... my $Path = sprintf("%s/inc",$ENV{'PAR_TEMP'});
    I get the directory in which I can find the files or directories packed into the PAR archive by the the pp "--addfile" option.

    Many thanks to everybody for contributions.

    Best greetings and wishes

    chanklaus

    Learning is like swimming against the current - as soon as you stop you'll drift back
    (Chinese proverb)
Re: PAR::Packer: pp with addfile option: where are the files?
by Beechbone (Friar) on Nov 05, 2013 at 14:37 UTC
    This comes up early on Google...

    Documentation is at http://cpansearch.perl.org/src/RSCHUPP/PAR-Packer-1.015/contrib/docs/where_is_it.txt

    BTW: The solution when running unter "clean" is not quite right. The files will be extracted, just to a different location. I found scanning @INC to be the simplest solution.

    sub extrafile($) { return $_.'/'.$_[0] if -e $_.'/'.$_[0] for @INC; die $_[0].' is missing'; }


    Search, Ask, Know