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

Can some one teach me how to use PAR. I want to put all my script in a single file so I could attach and email it to someone easily.

My script use web browser as interface and 100% perl sever. The server is called http.pl and all my script are in a /do/cgi-bin/ directory. So how do I combine my server and script into one file(eg .exe) and how to use the exe file.

TQ

Replies are listed 'Best First'.
Re: PAR: How to?
by tinita (Parson) on Jul 31, 2004 at 14:49 UTC
    i guess you just don't know that there exists lots of information on using PAR, for example directly on the cpan-site you will find:
    pp - The Perl Packager
    Tutorial
    FAQ
      Yes, I read it before, but I just couldn't understand when it involve file in different directories and, when it is in .exe form how do I use them? As the server.pl will search the file http://localhost:1010/cgi-bin/myp.cgi. myp.cgi is in the .exe file but how to call that file?
        As the server.pl will search the file http://localhost:1010/cgi-bin/myp.cgi.
        that is not a file, but a http-url. i don't get how your application architecture looks like.
        what exactly do you mean when you say "server.pl will search ..."? as it is a url i can only guess it does fetch the url via lwp.
Re: PAR: How to?
by Joost (Canon) on Jul 31, 2004 at 16:25 UTC
    If I understand you correctly you have more than 1 program: the http.pl server and one or more cgi scripts. PAR is not exactly made for that.

    If you need to, you could convert all the programs to stand-alone binaries usin PAR, put them in a directory tree and create a zip of that, but at least your server.pl needs to be aware that the whole tree is likely in a different location than it is on your machine.

    If you only have perl cgi scripts, you might be able to get the server.pl's perl interpreter to run the scripts, which means you only have to convert the server.pl and its modules with PAR and you can leave the rest unchanged.

    CGI apps are easy for remote users to access, they usually aren't particulary easy to install :-)

Re: PAR: How to?
by mattr (Curate) on Aug 02, 2004 at 05:09 UTC
    For what it's worth, I tried to something similar using Thinstall.

    I had to stop working on it because it was taking a lot of time to figure out, but am may take it up again soon for another project (in wxperl) if pp and an open source installer don't hack it. My problem in the past was that I couldn't get pp to install or run without crashing on the pc in question, and I really wanted to do it all in cygwin.

    Thinstall is nice commercial software and ought to work for Perl too, basically it makes a virtual filesystem you can pack all your files into. I was trying to pack apache, postgresql, and perl with its core modules into one archive to run a cgi using Class::DBI and view it in a browser.

    Needless to say the archive was heading around 40 mb last I saw it..

    Since you don't need a database or apache your case is more interesting. If you can figure out the dependent modules using pp, theoretically you could run it out of a thinstall archive (which would look like an exe). On the other hand you could also just use pp to package the main program and install the other files using an open source installer, which is a little less clean-looking but on the other hand, is a lot cheaper.

    Would like to see how you solve the problem. I looked around for virtual filesystems in an exe (or something from unix that could be applied) and the thinstall unix tools demo, which gives you a shell with many tools all in one exe, had stuck in my mind. My advice is first check out par's pp. Good luck!

    Matt R.