Monday, November 5, 2012

a working Perl on xampp

Returning to both Windows and Perl after something of an absence.

The XAMPP application stack is a quick way to get a web server, database and scripting languages onto a Windows box (& other platforms as well). I seem to remember that it was one of the very first one-click application server installers back in the mid-2000s.

Anyway, the version of Perl bundled in the current release (1.8.1) is broken from the point of view of  adding new modules. There's a complex Google trail to be followed but the upshot is: it awaits fixing. It's perfectly usable as a script interpreter but when you try to add modules from CPAN it's missing required system libraries and tools.

The simplest solution is to install Strawberry Perl, which is a port of the language and it's supporting ecosystem to win32 or 64:

* install xampp
* install strawberry perl
* check your environment variables to ensure that strawberry's perl.exe is in the system path (by default: C:\strawberry\perl\bin - rather than inside C:\xampp somewhere).
* alter the shebang line of any cgi scripts you want to call on xampp's apache server to point at strawberry perl (by default at: C:\strawberry\perl\bin\perl.exe).

So your cgi scripts will still live in the location defined in xampp/apache (default: C:\xampp\cgi-bin)  but they will call the strawberry interpreter instead of the bundled one.

This way, your can use the standard CPAN method of adding Perl modules from the command line (perl -MCPAN -e shell) and it will compile and install them into a location where they can be found by strawberry Perl (C:\strawberry\perl\site\lib) - i.e. it's INC path.

1 comment:

Unknown said...

My opinion: Great!
This helped me.
Thank you.