0

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?

Grinnz
  • 9,093
  • 11
  • 18
storm5510
  • 23
  • 3
  • This looks like there is a typo. You've declared a hash `%pp` and in the next line the reference is to `% pp` (note the space). This will certainly get rid of the syntax error. – jakub-olczyk Jan 10 '20 at 13:52
  • `pp` is a commandline tool that you run **on** code. – Botje Jan 10 '20 at 15:39
  • 2
    yes, pp -o ... is a command you are supposed to run. the `%` is supposed to indicate a command prompt – ysth Jan 10 '20 at 16:07

1 Answers1

0

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...

storm5510
  • 23
  • 3