Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Perl environment installation


May 13, 2021 Perl


Table of contents


Before we can start learning the Perl language, we need to install Perl's execution environment.

Perl can be 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
  • Wait a minute...

Perl is already installed by default on many system platforms, and we can use the following commands to see if it is installed:

$ 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 output above indicates that it is installed, and if it is not already installed, you can see the next installation instructions.


Install Perl

We can download the installation package for the corresponding platform on Perl's official website: https://www.perl.org/get.html

Perl environment installation

Unix and Linux install Perl

Perl installation steps on Unix/Linux systems are as follows:

  • Open the browser http://www.perl.org/get.html.

  • Download the source package for Unix/Linux.

  • After downloading the perl-5.x.y .tar.gz file, do the following.

    $ tar -xzf perl-5.x.y.tar.gz
    $ cd perl-5.x.y
    $ ./Configure -de
    $ make
    $ make test
    $ make install
    

Next we'll see if the perl -v command is installed successfully.

After successful installation, Perl's installation path is /usr/local/bin, the library is installed at /usr/local/lib/perlXX, and XX is the version number.

Window installs Perl

Perl has ActiveState Perl and Strawberry Perl compilers on the Window platform.

The biggest difference between ActiveState Perl and Strawberry Perl is that Strawberry Perl has some CPAN modules in it, so Strawberry Perl downloads more than 80 M of installation files, while ActiveState Perl has only about 20M.

We're using Strawberry Perl here.

The Perl installation steps on the Window system are as follows:

  • Strawberry installation package link: http://strawberryperl.com.

  • Download the version for your system: 32bit or 64bit.

  • After downloading, double-click open and follow the installation wizard to install it step by step.

Perl environment installation

Mac OS installs Perl

The Mac OS system generally has Perl installed by default, and if not, follow these steps:

  • Open the browser http://www.perl.org/get.html.

  • Download the source package for Mac OS.

  • After downloading the perl-5.x.y .tar.gz file, do the following.

    $ tar -xzf perl-5.x.y.tar.gz
    $ cd perl-5.x.y
    $ ./Configure -de
    $ make
    $ make test
    $ make install
    

Perl's installation path after successful execution is /usr/local/bin, the library is installed on /usr/local/lib/perlXX, and XX is the version number.


Run Perl

Perl has different ways of executing.

1, interactive

We can execute perl code directly on the command line in the following syntax format:

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

或 

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

The command line arguments are as follows:

Options Describe
-d[:debugger] Run the program in debug mode
-Idirectory Specify @INC/#include directory
-T

Contamination detection is allowed

-t Allow pollution warnings
-U Unsafe operations are allowed
-w Allow a lot of useful warnings
-W Allow all warnings
-X Disable the use of warnings
-e program Execute the perl code
file Execute the perl script file

2, script execution

We can put the perl code in the script file and execute the file code with the following commands:

$perl  script.pl          # Unix/Linux

或 

C:>perl script.pl         # Windows/DOS

Integrated Development Environment (IDE: Integrated Development Environment)

We can also execute perl scripts on some graphical user interface (GUI) environments. The following are two commonly used Perl integrated development environments:

  • Padre :P is an integrated development environment for Perl language developers that provides syntax highlighting and code refactoring capabilities.

  • EPIC: EPIC is a plug-in to the Perl Eclipse IDE, which you can use if you're familiar with Eclipse.

    Installation steps: Help--Eclipse Marketplace--enter EPIC--choose to install and update it.