Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

.pl to .exe

by andrew2003 (Initiate)
on Sep 03, 2003 at 13:15 UTC ( [id://288628]=perlquestion: print w/replies, xml ) Need Help??

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

Is there any way to convert a perl script to an executable (either in windows or Linux)?

Replies are listed 'Best First'.
Re: .pl to .exe
by Zeroth (Beadle) on Sep 03, 2003 at 14:01 UTC
Re: .pl to .exe
by cchampion (Curate) on Sep 03, 2003 at 13:45 UTC

    If you are looking for secrecy of your code, before diving into perl2exe, please read some caveats: perl2exe - no more secrets.

    The same node lists some alternatives.

      pp seems to make very large executables, a lot larger than perlapp. Anyone know why?
      it says she can do math, but will she recognize 8 / 0?

      We can only hope they've put in those safeguards.

      Worst case scenario: She succeeds in dividing by zero, and suddenly little Tiphany-Amber's bedroom becomes the center of a howling vortex of nonspace, frying the neighborhood with sparkling discharges of zero-point energy.

      - slashdot
Re: .pl to .exe
by pm5 (Acolyte) on Sep 03, 2003 at 13:47 UTC
    There is also perlcc, and PAR on CPAN, which contains a program "pp". Both of which can make standalone windows or linux executables. I've never tried any of them, though.
      PAR works quite well on Windows once you get it installed. I could not install it using ppm but I was able to install it like this:
      C:\>ppm install par-dist C:\>perl -MPAR::Dist -e "install_par('http://cpan.org/modules/by-autho +rs/id/A/AU/AUTRIJUS/PAR-0.74')"
      you then can create an executable by doing this:
      C:\>pp -o myscript.exe myscript.pl
      I recommend you then use upx to shrink the executable.
      I have to admit I haven't used it on any horribly complex scripts but it has alway worked on the ones I have tried. It is nice because you can use the .exe file on any windows computer even if it doesn't have perl installed. (even if you can't fit them on a floppy)

      Update: Try running this:

      C:\>pp -o hello.exe -e "print 'hello world!'" C:\>hello hello world!
      you get a nice 1.36M hello.exe which upx's down to 909k.

      --

      flounder

      On Linux, for some things, I call the Perl Program from a Bash Script. Then I turn the Bash Script into an executable icon in KDE, Howto is in the KDE menus somewhere. Then people can use the program without knowing anything about how your Linux comp works. That gives .exe type functionality.
Re: .pl to .exe
by cfreak (Chaplain) on Sep 03, 2003 at 17:42 UTC

    Perl2Exe and ActiveState's PerlApp are both commercial apps and i know that Perl2Exe is also non-free as in speech, not sure about PerlApp.

    perlcc is a pain to get dependencies right and even in the docs talks about being very experimental

    I would recommend PAR and its pp utility. I've used it a few times with great success. I think the executable is a bit larger but you can have it include all its dependencies without hassle. Its also free as in speech and beer :)

    Update I should add that the executable created by PAR is easily broken back down to the original source so if you are looking for a way to hide your source code (which I recommend against doing at all) then use a language you can compile.

    Lobster Aliens Are attacking the world!
Re: .pl to .exe
by snadra (Scribe) on Sep 03, 2003 at 13:35 UTC
    There is a tool called perl2exe, wich does what you are asking for, for windows and Unix. But I cannot tell you how good it is, since I never used it.
      Or Activestate's PerlApp, which basically does the same thing. Though, do only use this as a mechanism to ease installation, not as a way to hide your source, or even speed up your code. I think you can just open the executable in a hex editor or even a plain text editor, and just read the source.

      Pod-Browser and The GUI Loft are two examples of applications that can be downloaded in binary form. At least perl2exe does some encryption of the source, though as you can read in "perl2exe - no more secrets", it is easily broken.

      You might reconsider using PAR or maybe even tinyperl instead.

      p.s. AFAIK perlcc has been abandoned because of insurmountable problems. It didn't give any speed improvement anyway. So, don't use it.

      As a current Perl2Exe user I thought I might add my 2 cents to this discussion by doing a side by side comparison of the two compile methods. Now, before I go too far, I must say I just started playing with PAR today, so I'm not exactly an expert on using it. I'm sure there are better ways of using it to compile scripts, but this method seemed like the best way at the time.

      For starters, I use Perl2Exe mostly to create single EXE files (command line and GUI) for some of my users on Win32 boxes that don't require Perl, dependencies, or anything extra be installed. Adding Perl to each user's machine and synchronizing modules with everyone would not be worth the effort. One Application, one file. I really could care less about the fact that the embedded code is encrypted. Perl2Exe also provides the ability to compile your script for other platforms like Linux and Sun provided you have a $449 enterprise license. Not needing to port my scripts to other platforms, I could care less. So, for what I use it for, the $49 version Perl2Exe works just fine for me except when I sometimes need to create GUI apps. To get rid of that annoying command line window I could get the $149 version or just use another Perl script to flip the command line/windows app bit in the finished executable I pulled off this web site (sorry, can't remember the name, but it's here somewhere in a Perl2exe message thread). Since most of my scripts are command line based, I really don’t need to do that much. That said, let's move on.

      For the first test I took one of my old scripts that grabs scanned LEGO manuals off of the Brickshelf site at http://www.brickshelf.com by sego set number. It's a small, ~3K script that uses LPW to do the actual fetch of the JPG scans. Here's the compile results:
      C:\TOOLS\Perl>perl2exe legoscanfetch.pl Perl2Exe V5.03b Copyright (c) 1997-2002 IndigoSTAR Software [reg code removed] Converting 'legoscanfetch.pl' to legoscanfetch.exe C:\TOOLS\Perl>pp -o legoscanfetch.par.exe legoscanfetch.pl C:\TOOLS\Perl>pp -B -p legoscanfetch.pl C:\TOOLS\Perl>dir legoscanfetch.* Volume in drive C is drive label Volume Serial Number is 0566-16E9 Directory of C:\TOOLS\Perl 09/03/2003 04:39p 1,059,664 legoscanfetch.exe 09/03/2003 04:42p 300,618 legoscanfetch.par 09/03/2003 04:41p 1,499,944 legoscanfetch.par.exe 09/03/2003 04:36p 3,445 legoscanfetch.pl 4 File(s) 2,863,671 bytes 0 Dir(s) 13,508,353,536 bytes free C:\TOOLS\Perl>
      As you can see the Perl2exe version is a bit smaller. Just as a test, I moved both files over to another Win2k box that did not have Perl installed and ran them. Both worked, proving that the compiled executables were completely self contained. As for the PAR file, that's just in there for a size reference. Since it's not a completely self contained executable I'm not really interested in it, but this may be of interest to someone else.

      Now, on to the next test. For this I decided to see how well PAR could handle external DLLs. For a while I've been playing with WxPerl. I like it, but Perl2Exe does not seem to bundle the Wx DLLs into the executable by default. There's probably a way to do this, but I haven't bothered to look. For this test, I used one of the sample files included with WxPerl that just pops up a GUI window. To keep it simple, I opted to not get rid of the command line window that the compiled executable creates. Here's the compile results for the second test:
      C:\TOOLS\Perl\tests>perl2exe wx_sample.pl Perl2Exe V5.03b Copyright (c) 1997-2002 IndigoSTAR Software [reg code removed] Converting 'wx_sample.pl' to wx_sample.exe C:\TOOLS\Perl\tests>pp -o wx_sample.par.exe wx_sample.pl C:\TOOLS\Perl\tests>pp -B -p wx_sample.pl C:\TOOLS\Perl\tests>dir wx_sample.* Volume in drive C is drive label Volume Serial Number is 0566-16E9 Directory of C:\TOOLS\Perl\tests 09/03/2003 05:02p 2,328,374 wx_sample.exe 09/03/2003 05:05p 3,426,203 wx_sample.par 09/03/2003 05:03p 4,625,518 wx_sample.par.exe 05/30/2003 02:25p 1,448 Wx_Sample.pl 4 File(s) 10,381,543 bytes 0 Dir(s) 13,497,361,408 bytes free C:\TOOLS\Perl\tests>
      In this case, Perl2exe looks to be the clear winner in this case until you realize that the compiled executable requires three Wx DLLs to function. Not so bad you may say, that is until you see the size of the DLLs:
      C:\TOOLS\Perl\tests>dir *.dll Volume in drive C is drive label Volume Serial Number is 0566-16E9 Directory of C:\TOOLS\Perl\tests 05/30/2003 02:31p 1,124,352 Wx.dll 08/04/2002 04:41a 2,301,440 wx22_9.dll 05/19/2003 02:49p 3,225,600 wxmsw241.dll 3 File(s) 6,651,392 bytes 0 Dir(s) 13,494,103,040 bytes free C:\TOOLS\Perl\tests>
      And yes, all three DLLs are required for it to run, I checked. The PAR version worked without them (or with them depending on how you look at it). So, it looks like the 4.5M PAR version is the clear winner in the embedded DLL test.

      I'd ramble on a bit more, but this is getting a bit long, so I'll continue this in another post. Next test: benchmarks!

      Rick
Re: .pl to .exe
by CountZero (Bishop) on Feb 14, 2015 at 18:59 UTC
    Some background on all these programs to make a "stand alone" executable perl program.

    There is no actual compiling going on. These programs scan the script for dependencies and then pack everything needed, including the Perl executable, inside an archive file that knows how to unpack itself and run the included perl.exe with your script.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://288628]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-03-28 22:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found