How can I compile my Perl script so that it can run on systems without Perl?

I have a .pl file and I want to execute this file on any system, even if perl not installed. How can i achieve this?

Can someone let me know with some good examples for this?

+46
perl
Aug 6 '09 at 6:37
source share
9 answers

pp can create an executable that includes perl and your script (and any module dependencies), but it will be specific to your architecture, so you couldn’t run it on both Windows and Linux, for example.

From the doc:

Make a standalone executable file suitable for working on a computer on which perl is not installed:

  % pp -o packed.exe source.pl # makes packed.exe # Now, deploy 'packed.exe' to target machine... $ packed.exe # run it 

(% and $ have command prompts on different machines).

+39
Aug 6 '09 at 6:50
source share
  • Install PAR::Packer . Example for * nix:

      sudo cpan -i PAR :: Packer 

    For Strawberry Perl for Windows or for ActivePerl and MSVC:

      cpan -i PAR :: Packer 
  • Pack it with pp . It will create an executable file named "example" or "example.exe" on Windows.

      pp -o example example.pl 

This will only work on the OS where it was built.

PS It is very difficult to find a Unix clone without Perl. Did you mean Windows?

+24
Aug 6 '09 at 20:54
source share

Take a look at PAR (Perl Archiving Toolkit).

PAR is a cross-platform packaging and Deployment Tool called Cross between Java JAR and Perl2EXE / PerlApp .

+7
Aug 6 '09 at 6:50
source share

From perlfaq3 answer to How can I compile my Perl program into byte code or C? :




(contributed by brian d foy)

In general, you cannot do this. However, there are some things that may work for your situation. People usually ask this question because they want to distribute their work without giving away the source code, and most of the solutions are used for disk space for convenience. You probably won't see a big increase in speed either, as most solutions simply bundle the Perl interpreter in the final product (but see. How can I get my Perl program to work faster?).

The Perl Archive Toolkit ( http://par.perl.org/ ) is a Perl analogue of the Java JAR. It is freely available on CPAN ( http://search.cpan.org/dist/PAR/ ).

There are also some commercial products that may work for you, although you must buy a license for them.

The Perl Dev suite ( http://www.activestate.com/Products/Perl_Dev_Kit/ ) from ActiveState allows you to "turn your Perl programs into executable files for HP-UX, Linux, Solaris, and Windows."

Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command-line tool for converting perl scripts to executable files. It is designed for both Windows and Unix platforms.

+7
Aug 07 '09 at 3:12
source share

And don't forget the ActiveState PDK . This will allow you to compile the user interface, command line, Windows services, and installers.

I highly recommend him, he served me well for many years, but he is about $ 300 per license.

+6
Aug 06 '09 at 14:09
source share

Note to Sinan and Brian: perlfaq3 is still wrong.

See http://search.cpan.org/dist/BC/perlcompile.pod

+4
Dec 28 '10 at 18:56
source share

Cava Packager is great for the Windows ecosystem.

+3
Aug 6 '09 at 17:52
source share

Perl files are scripts, not executable programs. Therefore, in order to "run", they will need an interpreter.

So, you have two options: 1) Ask the translator on the machine that you want to run the script, or 2) Run the script on the network (or Internet) computer with which you connect remotely (i.e., with a browser).

+1
Aug 6 '09 at 6:51
source share

In MaxOSX it can be perlcc . Type of person perlcc. On my system (10.6.8), this is in / usr / bin. Ymmv

See http://search.cpan.org/~nwclark/perl-5.8.9/utils/perlcc.PL

0
Jul 13 '14 at 15:11
source share



All Articles