Perl Environment Installation
Before we start learning the Perl language, we need to install the Perl execution environment first.
Perl can run on the following platforms:
- Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX etc.)
- Win 9x/NT/2000/
- WinCE
- Macintosh (PPC, 68K)
- Solaris (x86, SPARC)
- OpenVMS
- Alpha (7.2 and later)
- Symbian
- Debian GNU/kFreeBSD
- MirOS BSD
- And so on...
Perl is already installed by default on many system platforms; we can check whether it is installed with the following command:
$ perl -v
This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
……
If the above information is output, it means it is installed; if not yet installed, you can look at the installation instructions below.
Installing Perl
We can download the installation package for the corresponding platform from the official Perl website:https://www.perl.org/get.html

Installing Perl on Unix and Linux
The steps to install Perl on Unix/Linux systems are as follows:
-
Open through the browser http://www.perl.org/get.html。
-
Download the source package suitable for Unix/Linux.
-
Download perl-5.x.y.tar.gz After downloading the file, perform the following operations.
$ tar -xzf perl-5.x.y.tar.gz $ cd perl-5.x.y $ ./Configure -de $ make $ make test $ make install
Next, if we perl -v command to check whether the installation was successful.
After a successful installation, the Perl installation path is /usr/local/bin , and the libraries are installed in /usr/local/lib/perlXX, where XX is the version number.
Installing Perl on Windows
On the Windows platform, Perl has the ActiveStatePerl and Strawberry Perl compilers.
The biggest difference between ActiveState Perl and Strawberry Perl is that Strawberry Perl includes more modules from CPAN, so the downloaded installation file of Strawberry Perl is over 80 MB, while ActiveState Perl is only about 20 MB.
Here we use Strawberry Perl.
The steps to install Perl on Windows systems are as follows:
-
Strawberry installation package link: http://strawberryperl.com。
-
Download the version corresponding to your system: 32bit or 64bit.
-
After downloading, double-click to open it and follow the installation wizard step by step.

Installing Perl on Mac OS
Perl is generally installed by default on Mac OS systems; if it is not installed, perform the following steps:
-
Open through the browser http://www.perl.org/get.html。
-
Download the source package suitable for Mac OS.
-
Download perl-5.x.y.tar.gz After downloading the file, perform the following operations.
$ tar -xzf perl-5.x.y.tar.gz $ cd perl-5.x.y $ ./Configure -de $ make $ make test $ make install
After successful execution, the Perl installation path is /usr/local/bin , and the libraries are installed in /usr/local/lib/perlXX, where XX is the version number.
Running Perl
Perl has different ways of execution.
1. Interactive mode
We can execute Perl code directly on the command line; the syntax format is as follows:
$perl -e # Unix/Linux
或
C:>perl -e # Windows/DOS
The command-line parameters are as follows:
| Option | Description |
|---|---|
| -d[:debugger] | Run the program in debug mode |
| -Idirectory | Specify the @INC/#include directory |
| -T |
Enable taint checking |
| -t | Enable taint warnings |
| -U | Allow unsafe operations |
| -w | Enable many useful warnings |
| -W | Enable all warnings |
| -X | Disable use warnings |
| -e program | Execute Perl code |
| file | Execute a Perl script file |
2. Script execution
We can put Perl code in a script file and execute the code in the file with the following command:
$perl script.pl # Unix/Linux
或
C:>perl script.pl # Windows/DOS
Integrated Development Environment (IDE: Integrated Development Environment)
We can also execute Perl scripts in some Graphical User Interface (GUI) environments. The following two commonly used Perl integrated development environments are recommended:
-
Padre: Padre is an integrated development environment provided for Perl language developers, offering syntax highlighting and code refactoring features.
-
EPIC : EPIC is a plug-in for the Perl Eclipse IDE; if you are familiar with Eclipse, you can use it.
Installation steps: Help-->Eclipse Marketplace-->enter EPIC-->select install and update.
