Creating an executable program from a Perl script

2.2k Views Asked by At

I am trying to make an executable program from a finished perl script. I installed the PAR::Packer module without difficulty. However, I do not believe I am doing this properly. Below is the code inside the script I want to compile:

use PAR::Packer qw(pp);

my %pp;
% pp -o prlgap.exe prlgap.pl;

The above is an example I found on Perl Monks. If I run the script and I get the following errors:

Unquoted string "prlgap" may clash with future reserved word at
C:\Strawberry\prlgap.pl line 15. Syntax error at
C:\Strawberry\prlgap.pl line 15 near "% pp -o "

The third line in the code is line 15. It seems strange to attempt to compile a program by running it. In my experience, this has always been done externally. What am I missing?

1

There are 1 best solutions below

0
storm5510 On

After some web searching, I found this is done externally. Simply pp program.pl at the command prompt. The caveat, doing this really puts the brakes on if you have something which runs a loop rapidly. Also, the resultant executable was really large. My 65 line script compiled into an eight-megabyte program, after I removed any modules it did not need. The Strawberry installer adds environment variables which makes running a script from anywhere on a drive possible. It only requires the .pl extension to be added to the name. Program.pl for example.

Thank all of you for your replies...