FAQ 3.21 How can I compile my Perl program into byte code or C?



This is an excerpt from the latest version perlfaq3.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

3.21: How can I compile my Perl program into byte code or C?

(contributed by brian d foy)

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

The Perl Archive Toolkit ( http://par.perl.org/ ) is Perl's analog to
Java's JAR. It's freely available and on CPAN (
http://search.cpan.org/dist/PAR/ ).

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

The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ )
from ActiveState can "Turn your Perl programs into ready-to-run
executables for HP-UX, Linux, Solaris and Windows."

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



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
.