How to install Perl and confirm the installation

To install Perl on Windows 10, I went to perl.org and followed the links to get to the Windows Binaries, where I clicked a link to download ActivePerl. The name of the file that was downloaded was ‘ActivePerl-5.24.3.2404-MSWin32-x64-404865.exe’.

Then I installed Perl by clicking the .exe. Note: On one of the installation screens I chose the option to make sure that Perl was added to my system path. When the installation was complete, I checked my system Path to look for the new entries. I saw that these two entries were added:

  • C:\Perl64\site\bin
  • C:\Perl64\bin

Then to confirm the installation, I opened up a command window and typed:

perl -v

Which confirmed the installation:

Then I ran a test of Perl by running a script called printenv.pl in my local Apache server cgi-bin. It produced the following output:

COMSPEC="C:\WINDOWS\system32\cmd.exe"
CONTEXT_DOCUMENT_ROOT="C:/Bitnami/wampstack-7.1.14-0/apache2/cgi-bin/"
CONTEXT_PREFIX="/cgi-bin/"
DOCUMENT_ROOT="C:/Bitnami/wampstack-7.1.14-0/apache2/htdocs"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_ENCODING="gzip, deflate"
HTTP_ACCEPT_LANGUAGE="en-US,en;q=0.5"
HTTP_CONNECTION="keep-alive"
HTTP_HOST="localhost"
HTTP_UPGRADE_INSECURE_REQUESTS="1"
HTTP_USER_AGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0"
OPENSSL_CONF="C:\Bitnami\wampstack-7.1.14-0/apache2/conf/openssl.cnf"
PATH="C:\Bitnami\wampstack-7.1.14-0/apache2/bin;"
PATHEXT=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
QUERY_STRING=""
REMOTE_ADDR="::1"
REMOTE_PORT="52686"
REQUEST_METHOD="GET"
REQUEST_SCHEME="http"
REQUEST_URI="/cgi-bin/printenv.pl"
SCRIPT_FILENAME="C:/Bitnami/wampstack-7.1.14-0/apache2/cgi-bin/printenv.pl"
SCRIPT_NAME="/cgi-bin/printenv.pl"
SERVER_ADDR="::1"
SERVER_ADMIN="admin@example.com"
SERVER_NAME="localhost"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE=""
SERVER_SOFTWARE="Apache"
SYSTEMROOT="C:\WINDOWS"
WINDIR="C:\WINDOWS"

The Perl code in this script looks like this:

#!C:/Perl64/bin/perl.exe
##
##  printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}

For more information, see:
https://www.perl.org
https://www.perl.org/get.html#win32