Easy Tutorial
❮ Perl Until Loop Perl Data Types ❯

Perl Environment Installation

Before we start learning Perl, we need to install the Perl execution environment.

Perl can run on the following platforms:

Many system platforms come with Perl pre-installed. We can check if it is installed by running 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 you see the above output, it means Perl is installed. If not, follow the installation instructions below.


Installing Perl

You can download the installation package for your platform from the official Perl website: https://www.perl.org/get.html

Unix and Linux Installation of Perl

The steps to install Perl on Unix/Linux systems are as follows:

Next, check if the installation was successful by running the perl -v command.

After successful installation, Perl will be located at /usr/local/bin, and the libraries will be installed in /usr/local/lib/perlXX, where XX is the version number.

Windows Installation of Perl

Perl has ActiveStatePerl and Strawberry Perl compilers for the Windows platform.

The main difference between ActiveState Perl and Strawberry Perl is that Strawberry Perl includes more modules from CPAN, so the Strawberry Perl installation file is about 80MB, while ActiveState Perl is around 20MB.

We will use Strawberry Perl here.

The steps to install Perl on Windows are as follows:

Mac OS Installation of Perl

Mac OS systems typically come with Perl pre-installed. If it is not installed, follow these steps:

After successful execution, Perl will be located at /usr/local/bin, and the libraries will be installed in /usr/local/lib/perlXX, where XX is the version number.


Running Perl

Perl can be executed in different ways.

1. Interactive Mode

You can execute Perl code directly in the command line with the following syntax:

$ perl -e <perl code>           # Unix/Linux

or

C:> perl -e <perl code>          # Windows/DOS

The command line options are as follows:

Option Description
-d[:debugger] Run program in debugger
-Idirectory Specify @INC/#include directory
-T Enable taint checks
-t Enable taint warnings
-U Allow unsafe operations
-w Enable useful warnings
-W Enable all warnings
-X Disable all warnings
-e program Execute Perl code
file Execute Perl script file

2. Script Execution

You can place Perl code in a script file and execute it with the following command:

$ perl script.pl          # Unix/Linux

or

C:> perl script.pl         # Windows/DOS

Integrated Development Environment (IDE)

You can also execute Perl scripts in some graphical user interface (GUI) environments. Here are two recommended Perl IDEs:

Installation steps: Help --> Eclipse Marketplace --> Enter EPIC --> Select and install.

❮ Perl Until Loop Perl Data Types ❯