Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

using a Perl script in Windows without installing perl

by evgen-i (Novice)
on Dec 17, 2012 at 14:45 UTC ( #1009179=perlquestion: print w/ replies, xml ) Need Help??
evgen-i has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am faced with the following situation:

1. I have a Perl script that cleans up text in different human languages with regular expressions. It uses Perl modules which I created for each such language (Arabic, Chinese, etc.). This script already runs in a production system that does something with the cleaned-up text.

2. This production system and my script now have to be ported to Windows and given to a customer, but with a condition that the customer should NOT be forced to install Perl. This means that somehow:

  • either the Perl interpreter should be statically linked into some C/C++ program calling my Perl script;
  • or the perl script should be embedded into this C/C++ program
  • or both.
  • 3. My question is how to do this porting to Windows best? I tried using perlembed, but had difficulties with including the modules. The other difficulty is that the script will be continuously updated/improved under Linux, which means that its Windows update should be as quick and easy as possible.

    Thank you!


    Comment on using a Perl script in Windows without installing perl
    Re: using a Perl script in Windows without installing perl
    by marto (Chancellor) on Dec 17, 2012 at 14:53 UTC

      You could use pp to package your script along with all dependant modules into an exceutable which will run without having to install Perl on the target system. Note that you need to create the Windows executable on a system running Windows with Perl, pp and all of the other modules/files your script needs. Each time you finish an update cycle on Linux you can repackage your application. If you have a release management system you may be able to automate this whole process quite easily.

      Please note that the resultant exe is essentially a zip file containing your code, the modules in question and whatever else you've packaged. Read PAR::FAQ and

        Thanks much, it seemed to work out-of-the-box for a simple test script.

        However, there is one problem: I am used to

        #!/usr/bin/perl -s

        This means that options specified as -a -b=1 are directly used in the script as $a and $b. After packaging with pp, though, the options are not recognized anymore. Do you know if there is a solution which can still keep these options?
    Re: using a Perl script in Windows without installing perl
    by Anonymous Monk on Dec 17, 2012 at 15:06 UTC
    Re: using a Perl script in Windows without installing perl
    by aitap (Deacon) on Dec 17, 2012 at 16:04 UTC

      pp can pack the whole program with its dependencies into a single executable file, which, when run, extracts itself in a temporary directory and runs Perl from there.

      If you don't want to waste time and disk space on unpacking the program, you'll have to try something else. Right now I'm searching for an answer for this question too, selecting between Cava Packager, packaging portable Strawberry Perl in an installer, running a copy of perl.exe + perl5xx.dll (or self-built perlembed) on an extracted PAR archive or something else.

      Sorry if my advice was wrong.
    Re: using a Perl script in Windows without installing perl
    by rpnoble419 (Pilgrim) on Dec 17, 2012 at 16:17 UTC
      I use ActiveState PerlApp or Perl2Exe from IndigoStar. Both work very well in this type of solution. If I make a DOS version of the script the command line args are still passed to the new perl exe. This should solve your issue. If you want to keep your client from having to input these command line args each time, ship a .bat file that calls the script.exe file with the correct args and you should be fine....

    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://1009179]
    Approved by marto
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (21)
    As of 2014-07-25 16:22 GMT
    Find Nodes?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:

      Results (173 votes), past polls