Home > Software design >  How to compile a Perl script to a Windows executable with Strawberry Perl?
How to compile a Perl script to a Windows executable with Strawberry Perl?

Time:11-15

What would be the easiest way to compile a simple Perl script to an executable under Windows with Strawberry Perl (as I understand it's possible and free)?

In the past I've used ActiveState compiler and perl2exe and was simple enough. However, now after a few computer changes and OS updates I've lost the licenses and I'd like to find a better/permanent solution.

CodePudding user response:

Install PAR::Packer from CPAN (it is free) and use pp utility.

CodePudding user response:

  :: short answer :
  :: perl -MCPAN -e "install PAR::Packer" 
  pp -o <<DesiredExeName>>.exe <<MyFancyPerlScript>> 

  :: long answer - create the following cmd , adjust vars to your taste ...
  :: next_line_is_templatized
  :: file:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
  :: disable the echo
  @echo off

  :: this is part of the name of the file - not used
  set _Action=run

  :: the name of the Product next_line_is_templatized
  set _ProductName=morphus

  :: the version of the current Product next_line_is_templatized
  set _ProductVersion=1.2.3

  :: could be dev , test , dev , prod next_line_is_templatized
  set _ProductType=dev

  :: who owns this Product / environment next_line_is_templatized
  set _ProductOwner=ysg

  :: identifies an instance of the tool ( new instance for this version could be created by simply changing the owner )   
  set _EnvironmentName=%_ProductName%.%_ProductVersion%.%_ProductType%.%_ProductOwner%

  :: go the run dir
  cd %~dp0

  :: do 4 times going up
  for /L %%i in (1,1,5) do pushd ..

  :: The BaseDir is 4 dirs up than the run dir
  set _ProductBaseDir=           
  • Related