void_Anthony() has asked for the wisdom of the Perl Monks concerning the following question:

I am becoming tired of having to use the perl interpreter everytime i want to run a perl program. Is there any utility someone knows of that can efficiently make a .exe out of a perl program? Any suggestions are appreciated. -Thank you for your time.

Replies are listed 'Best First'.
Re: Perl executables?
by davidrw (Prior) on May 11, 2005 at 19:48 UTC
    Check out PAR, and there are a couple others including (i'm assuming you're on windows) one that comes with activatestate's IDE.
Re: Perl executables?
by polettix (Vicar) on May 11, 2005 at 23:20 UTC
    Just to add my 2c tips...

    If you're simply bored to call your script like this:

    perl myscript.pl arg1 arg2 ...
    you can set a "shebang" if you're in Linux/Unix putting the following line at the very beginning of your script1:
    #!/path/to/perl
    (usually /usr/bin/perl) and setting the file's executable flag at least for you:
    $ chmod u+x myscript.pl
    If you're in Windows, associate the perl executable as default action for double-clicking on the script, as suggested by other monks.

    If you really want an executable, but just for fun and you can accept some degree of uncertainty about the results, you can use the perlcc compiler, which should generate a C source file from your Perl script. You can peruse perlcc for details, but be sure to read the disclaimer:

    The code generated in this way is not guaranteed to work. The whole codegen suite ("perlcc" included) should be con- sidered very experimental. Use for production purposes is strongly discouraged.
    AKA: caveat emptor.

    1I mean that you must start the given line from the first byte of your script.

    Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

    Don't fool yourself.
Re: Perl executables?
by rduke15 (Beadle) on May 11, 2005 at 22:28 UTC

    It's not very clear for me what you really want or why. I suppose you are on Windows, or you wouldn't have that sort of question/problem. Here are the options i know:

    • perl2exe (as others have already mentioned) makes big (1+ MB) executables containing the Perl interpreter along with your script and required modules.
    • pl2bat needs Perl installed. It encapsulates your perl script into an executable windows batch file (through the use of a few simple but smart tricks to hide the 2 different languages from each other; have a look at the .bat file).
    • map the .pl extension to Perl. Also needs Perl installed. The relevant commands to create the mapping are assoc and ftype. Type help ftype for an example. (I don't recommend this. Depending on what your scripts do, an accidental double-click can do quite some damage).

    What I recently did on a small (~ 15 people) network is to put Perl and various little utilities on the server, and added this to the logon script:

    setx PERLBIN \\Serv\apps\Perl\bin
    setx PERL5LIB \\Serv\apps\Perl\lib:\\Serv\apps\Perl\site\lib
    setx BIN \\Serv\apps\bin
    setx PATH %PERLBIN%;%BIN%
    

    setx can be found somewhere on the Microsoft site. It's from some resource kit.

Re: Perl executables?
by displeaser (Hermit) on May 12, 2005 at 09:40 UTC
    In Windows I use activestates "Perlapp" and find it excellent. Appears to have a smaller memory footprint then perl2exe, though the size of the exe can grow quite large if you have a lot of modules in the script you are converting (though all the methods of creating an exe from Perl would probably suffer from this). I'm not sure about other os's
Re: Perl executables?
by displeaser (Hermit) on May 12, 2005 at 09:51 UTC
    Sorry about another post. Forgot to mention you could also try http://tinyperl.sourceforge.net/. It's buggy but works (though I've only tried a few small scripts and nothing major with it)
Re: Perl executables?
by xorl (Deacon) on May 11, 2005 at 19:47 UTC
    Not sure why you really want to but try Perl2exe
      There are several perfectly valid reason he would want to do this. I will give the one that has come up more than once:

      Not all software is developed for in house use, which can lead to following problems:

      1. Many people (clients) don't understand the concept of an interpreter (Why can't I just click on it? What is that black DOS window that pops up, etc)
      2. Deploying the Perl interpreter on many machines could become a large task.
      3. Even if they have Perl installed, you have to be sure they have all the modues you need (Tk, LWP etc)
      4. It is ever so much easier to deliver 1 executable file, rather than a host of supporting modules as well as the whole Perl interpeter.

        in support of what scmason mention's. If you package the new exe up as an MSI file (microsoft Installer) you can distribute it through active directory which makes life a lot easier for a poor busy admin :-) I use activestates "perlmsi" to create these packages and then distribute them to appropriate OU's (organisational Unit).
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.