Uggles has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to Perl, but I have been given a perl script and a perl module file that converts an input file to a different file type. I have been told to look for options to make these two files into a standalone executable that can be run on any Windows machine (I'm not sure whether I'll have to make one that's 64 bit and one that's 32 bit, but I don't think that is an important issue as of now) by simply dragging and dropping the input file onto the executable.

I have looked through the options (pp, perl2exe, etc.) and have pretty much decided on pp because it's free and seems like it's pretty easy to use. I can make an executable with pp and I know that it includes the modules that I need (or at least I know how to include those modules), but how do I include the module given to me that isn't in cpan? I tried just including it in the files for the executable, but that doesn't seem to work.

So in summary, I want to create an executable from a perl script and perl module that runs the script when given an input file. Thanks for any help!

Replies are listed 'Best First'.
Re: Making a standalone executable
by FloydATC (Deacon) on Jun 03, 2013 at 18:01 UTC

    It seems to me all you need is a perl script that slurps something from STDIN (or a file?), and then uses eval() to execute that something. Then use pp to wrap that tiny script up with the modules you know you'll be needing and that's it. Sort of a custom flavored portable perl. Here's the concept code, untested:

    #!perl use strict; use warnings; local $/; my $script = <STDIN>; eval($script);

    Or maybe I missed something :-)

    -- FloydATC

    Time flies when you don't know what you're doing

      I think the problem was that I wasn't adding the custom module file using the add module function with pp. I have an executable that works on my computer, but the executable has a camel logo. I'm assuming that means that it is associated with perl in some way. I'm trying to see if it works on a computer without perl installed right now, but it doesn't seem like it does. Am I just not including the interpreter in the executable?

      Here's the line of code that I wrote to create the executable:

      pp -M "custom module" -o filename.exe perlscript.pl

        As a side note to your post, the camel logo is the default provided by pp. You can specify another icon of your choosing: pp -i yourappicon.ico .....

        .

      Nevermind, it looks like it works. I was getting compatibility errors when trying to run it on a computer without any sort of perl interpreter before, but that was because it was 32 bit. It worked on a 64 bit machine. Is there any easy way to create the same executable except make it 32 bit?

        It sounds like you used a 64 bit version of Perl to create your executable. In that case, you built a 64 bit executable, which can only be used in 64 bit Windows. Unless you need the 64 bit features of 64 bit Perl, you can install and use 32 bit Perl in 64 bit Windows. If you use 32 bit Perl to create your executable via pp, your executable can be run from both 32 bit and 64 bit Windows.