Perl scripts for perl-less people

Today I needed to hack to together a quick perl script that was to run on another person’s computer. It would have been total overkill to install cygwin and perl on his machine just to run a 10 line script. So instead I googled and determined that I could compile my script using a program included with perl called perlcc. I was doubtful that it would work under windows, but I decided to try anyways. It worked! So here is a quick how to compile perl under windows using cygwin and perlcc.

First off run perlcc –help. My script was simple with no extra modules, but yours might be more complex - the help screen will pick up where this simple howto fails.

In the same directory as your perl file run:
perlcc -o foo.exe foo.pl

Then open the folder in windows explorer and double click on foo.exe. It will probably complain about a missing dll (cywin1.dll will probably be the first one). Copy cygwin1.dll from /bin (C:\cygwin\bin) to the folder. Run it again and it will complain about a perl dll. Copy the perl dll (again from /bin) to the same folder. Repeat the process until you have all of the dlls it wants and your script runs in a DOS window. Now you should be able to send this folder to anyone and they can run foo.exe from it. Even after all these years perl still gives me the warm fuzzies.

Related posts:

Hello Open Source World
I have been using Open Source software for a long time. I used to be happy just getting free software in the form of shareware downloaded from local BBS's (I just remembered a random dream from one of the last few nights...

Web 2.0 in a web 1.0 world
It has been an interesting week of hacking. These days it is rare to even have to think about efficient code. Memory and processing power are seemingly limitless, except when they are not. And this week they are not. First off, I have been...

2 Comments »

  1. Leannonn said,

    March 30, 2006 @ 9:47 am

    Hi,

    I’ve tried that, but after it says:

    ‘cl’ is not recognized as an internal or external command,
    operable program or batch file.
    ‘link’ is not recognized as an internal or external command,
    operable program or batch file.

    Any ideas what might be wrong? Thanks…

    Leannonn

  2. Mike said,

    March 30, 2006 @ 9:52 am

    Is that the result of perlcc running, or the results of your compiled perl program?

RSS feed for comments on this post · TrackBack URI

Leave a Comment

You must be logged in to post a comment.

ok