%% mpicp-windows.tex
%% May 2011
%% RWD Nickalls

%% todo: check Crimson editor URL

\documentclass[mathsPICmanual.tex]{subfiles}
\begin{document}
%%=============================
\chapter{Installing Perl in MS-Windows}


Perl is available for all MS-Windows platforms, and there are several Perl implementations to choose from.
A good choice (which we describe here) would seem to be the free ActiveState  implementation of Perl  in view of their excellent web site, documentation and other resources.

\section{Perl}

The free ActivePerl implementation is a well regarded choice of Perl  for the Win32 platform, and is easy to download and install. The current version for download at the time of writing is Perl~5.8.6. There is excellent web support (e.g.~documentation etc)  via their ASPN website (ActiveState Programming Network).
\begin{itemize}
\item \url{http://www.activestate.com/Products/ActivePerl/}

\item \url{http://aspn.activestate.com/ASPN/docs/ActivePerl/}
\end{itemize}
The complete ActivePerl package consists of the following:-
\begin{itemize}
\item Perl (binary core Perl distribution)

\item An installer package

\item Perl Package Manager (PPM---a Perl extension installer and manager)
\item Documentation
\item Perl ISAPI (IIS plug-in that enhances the speed of standard Perl)

\item PerlScript (ActiveX scripting engine)

\item PerlEz (embedded Perl)
\end{itemize}


%%----------------------------------
\subsection*{Installation}

A useful installation guide can be found at \url{http://www.activestate.com/ASPN/docs/ActivePerl/install.html}.


In addition to  the Perl system itself, the older   Windows systems 2000/NT also require you to download a special `installer' package (\texttt{instMsiW.exe}) to implement the installation (see below).
Note that the filename and sizes indicated below are those at the time of writing.



%---------------
\subsubsection*{Step 1:}
First, create a temporary directory for files which need to be downloaded.
Then go to the ActiveState  web-site (\url{http://www.activestate.com/}) and click on the Language/ActivePerl link which will take you to the ActivePerl page. Follow the `download' links until you reach the `download' page (you can skip the `contact-info' section by clicking the `next' button), and then read the Windows section for the latest version of ActivePerl (version 5.8.6).

 %------------------
\subsubsection*{Step 2:}
Download the latest  ActivePerl \texttt{.msi} file (approx $12$\,MB). {\newline}For example, {ActivePerl-5.8.6.811-MSWin32-x86-122208.msi}


%-------------------
\subsubsection*{Step 3:}
Installation: the exact procedure depends on your particular Windows system as detailed below. The default installation is the recommended `complete' installation.

\begin{itemize}

 \item Windows~XP/2003:

 To install simply double click on the ActivePerl  \texttt{.msi} file  and follow the instructions (these systems do \textit{not} require a separate installer file).
\end{itemize}



%---------------------------
\subsection*{Running Perl}

Now that Perl is installed, we can progress to creating and  running a Perl program.
To create a  Perl program, simply open your favorite text-editor (see below for information on some suitable text-editors) and write the program (as an ASCII text file),  and finally save it with a \verb!.pl! extension.

For example, open  a new file and type the following into it, and then save it with the file-name \verb!test.pl! (note that in Perl the \# sign is the `comment' symbol; the \verb!\n! starts a new line; variable names start with a \verb!\$!).
\begin{center}
\fbox{%
\begin{minipage}{8cm}
\texttt{\#!/usr/bin/perl}
\newline\texttt{\# test.pl}
\newline\texttt{print "hello world$\backslash$n";}
\newline\texttt{\$a=3, \$b=7;}
\newline\texttt{\$sum=\$a + \$b;}
\newline\texttt{print "sum = \$sum$\backslash$n";}
\end{minipage}
}
\end{center}
When this is run it will show the following output
\begin{verbatim}
hello world
sum = 10
\end{verbatim}



We can run this Perl program several ways, as follows.

\begin{itemize}

\item Use the command-line:

Open a DOS box, move to the required directory,  and at the command-line prompt type the following command, and then press \verb!<enter>!
\begin{verbatim}
perl test.pl
\end{verbatim}
The output generated by the program will be written to the screen in the usual way. If you want the output written to a file (say. \verb!test.txt!) then instead type  \verb!perl test.pl > test.txt!

\item Click on the filename

If you just click on the filename in the directory listing (provided it has the \verb!.pl! filename extension) then ActivePerl will automatically open a DOS box, run the program, and then close the DOS box. This is fine if the program output is directed to a file, but if the output is simply directed to the screen (the default) then  you need to add the \verb!<>! command at the end of the file, as this will keep the screen open (so you can read the screen) until you hit a key.
\begin{center}
\fbox{%
\begin{minipage}{10cm}
\texttt{\#!/usr/bin/perl}
\newline\texttt{\# test.pl}
\newline\texttt{print "hello world$\backslash$n";}
\newline\texttt{\$a=3, \$b=7;}
\newline\texttt{\$sum=\$a + \$b;}
\newline\texttt{print "sum = \$sum$\backslash$n";}
\newline\texttt{\# -------------------}
\newline\texttt{print "press any key to exit$\backslash$n";}
\newline\texttt{<>}
\end{minipage}
}
\end{center}




\item Using a batch file:

Create a separate batch file with the name, say, \verb!test.bat! containing the following  lines:
\begin{verbatim}
perl test.pl %1 %2
\end{verbatim}
 This batch file now has to be run at the command-line as shown above.
 Note that ActivePerl can create  a batch file from an ordinary perl program by using the command utility \verb!pl2bat.bat!. Simply  access the command-line and type
\begin{verbatim}
pl2bat test.pl
\end{verbatim}
which will then generate the file \verb!test.bat! which can then be run at the command-line by just typing \verb!test!.
\end{itemize}


\subsection*{Perl modules}
Additional modules can be downloaded from the huge Perl archives available on the internet. These  Perl modules can be installed either automatically (via the internet using the PPM utility), or manually (download the module and then use the \verb!nmake! utility).
The \verb!nmake! utility is a Microsoft port of the Unix \verb!make! utility, and can be downloaded from the Microsoft internet archive at
\url{ftp://ftp.microsoft.com/Softlib/MSLFILES/}. The current version is bundled in the self-extracting package \verb!nmake15.exe!


%--------------------------
\subsection*{Useful Perl links}

\begin{itemize}
 \item  \textit{Introduction to Perl on Windows.} \newline\url{http://www.wdvl.com/Authoring/Languages/Perl/Windows/}

 \item CPAN Perl Ports (binary distributions).
\newline\url{http://www.cpan.org/ports/index.html}

 \item How to install Perl modules.
\newline\url{http://www.cpan.org/modules/INSTALL.html}

 \item Perl documentation.
\newline\url{http://www.perldoc.com}


\end{itemize}



%%---------------------------
\section{Text editors}

\subsubsection*{Crimson Editor (free)}
This is a good straight-forward `all-purpose' editor for Win-32 platforms, with good syntax highlighting, available from \url{http://crimson.emeraldeditor.com/}



\subsubsection*{WinEdt (shareware)}
This  is an excellent `all-purpose' text editor designed for use with \TeX\ and \LaTeX; it has syntax highlighting and can be tailored for use with Perl. It is available for download from \url{http://www.winedt.com/}. Note that a free licence for this editor is  provided as a membership benefit by many \TeX\ User Groups (e.g.~ukTUG).


%%------------------------
\subsubsection*{WinEDIT}

The WinEDIT PowerPack is an excellent (commercial)  general purpose text editor available for download (21-day free trial) from \url{http://www.winedit.com/}. It is  very similar to WinEdt, and has the useful facility for column copying/pasting,
and also an optional vertical window holding the  directory tree.



%-------------------------------------
\subsubsection*{GNU Emacs (free)}
This is a public domain (free) text editor. It is available from the GNU distribution page as follows
\url{http://www.gnu.org/software/emacs/windows/}.
See also Harry Halpin's excellent web page entitled \textit{How to install Perl and Emacs on a Windows machine} which can be found at \url{http://lcb.unc.edu/software/perl/perl.html}.




\end{document}
