Running Perl Scripts

WampDeveloper Pro is primarily a PHP web-server, but it does come with Perl (StrawberryPerl distribution), and is able to run Perl scripts out-of-the-box.

Simple Perl Scripts

For simple single-file Perl scripts (and not entire Perl based applications), just place the Perl scripts into the website’s already existing \cgi-bin folder (it is outside of \webroot) –

Then you can access those scripts via URL –

The provided \cgi-bin folder is configured to treat all files in it as executable CGI scripts (regardless of their file-name extension), and also does not allow for .htaccess files.

Entire Perl Applications

For more complicated Perl applications –

Because of the size and complexity of some Perl applications, it is not going to be good enough to place these perl applications into the website’s default \cgi-bin folder… We will rather have to place the application into the website’s \webroot folder, and enable CGI execution in the application’s folder…

Edit the website’s VirtualHost file (select website in Websites Tab, click VirtualHost buttons), inside the <VirtualHost> block add in…

<Directory "C:/WampDeveloper/Websites/">    
    Options -Indexes +ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
    # Execute file-names with .cgi and .pl extensions
    AddHandler cgi-script .cgi .pl

    <IfVersion <= 2.2>
    # Clients should be allowed to figure out the content-type themselves (for unknown/not-set mime types)
    #DefaultType text/html

Also, inside the above Directory block in the HTTPS VirtualHost, add line:
SSLOptions +StdEnvVars

Save files. Restart Apache.

If Apache won’t start, from the command-line (button in System Tab), run –

httpd -t -n "WampDev.Apache"
httpd -k start -n "WampDev.Apache"

This will tell you which lines in the VirtualHost file have errors in them.

Extra Perl Modules

Some Perl applications might also require extra Perl modules to be installed. To do so, open the command-line (button in System Tab) –

Then run something similar to this (substitute in package-names) –

perl -MCPAN -e shell;
install package::name1
install package::name2

This might, or might not, work out well – depending on the extra modules and what they require.

2 thoughts on “Running Perl Scripts”

  1. WampDeveloper’s configuration (Config\Apache\extra\wampd-cgi.conf) defaults to using:
    ScriptInterpreterSource Registry-Strict

    Registry-Strict” uses the script interpreter as defined in the Registry per the given file extension (*.pl). And only if this value is not defined in the Registry (regardless if the provided interpreter path is correct or not), does it attempt to read the “shebang” line (path to interpreter) of each script file.

    When WampDeveloper is installed, it sets in the Registry:

    Key: HKEY_CLASSES_ROOT\.pl\Shell\ExecCGI\Command
    Value name: (default)
    Value type: REG_SZ
    Value data: C:\WampDeveloper\Tools\Perl\perl\bin\perl.exe

    If you need to execute *.cgi files as Perl scripts:
    1. Update Configuration for file extension (if needed):
    AddHandler cgi-script .pl .cgi
    2. Set Registry Key/Value with the path to perl.exe:

    If you do not want to use the Registry at all (and just want to use the “shebang” line), you can set ScriptInterpreterSource in the Directory block:
    ScriptInterpreterSource Script

    And set the proper “shebang” line (that contains proper path to interpreter) in each script file.

    The “shebang” line is the first line in the script file, that provides the path to the script interpreter. It has the form (using forward-slashes):

  2. We are heavy users of Perl faced with using Perl and custom Perl libraries (*.pl).

    Assume for the moment our Strawberry Perl is at F:\Perl\perl.exe. Would you provide an example of the Registry setting required for:

    “2. Set Registry Key/Value with the path to perl.exe:

    Would a correct example of the registry entry be:

    Is there a similar way to designate a subdirectory where custom Perl libraries (usually named “vendor”) are accessible to all websites?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>