Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

using a Perl script in Windows without installing perl

by evgen-i (Novice)
on Dec 17, 2012 at 14:45 UTC ( [id://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!

    Eugene.
    • Comment on using a Perl script in Windows without installing perl

    Replies are listed 'Best First'.
    Re: using a Perl script in Windows without installing perl
    by marto (Cardinal) 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 http://par.perl.org.

        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 aitap (Curate) 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....
    Re: using a Perl script in Windows without installing perl
    by Anonymous Monk on Dec 17, 2012 at 15:06 UTC

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others lurking in the Monastery: (4)
    As of 2024-04-24 00:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found