Latest web development tutorials

Perl installation environment

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

Perl can be run under 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 many more...

Many on the system platform has been installed by default perl, we can use the following command to see if you have 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 information described above is installed, if not already installed, you can see the following installation instructions.


Installation of Perl

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

Unix and Linux installation Perl

Perl installation steps on Unix / Linux system is as follows:

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

  • Download for Unix / Linux source code package.

  • Do this after you downloadperl-5.xytar.gz file.

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

Next, if weperl -v command to see if the installation was successful.

After successful installation, the installation path Perl is/ usr / local / bin,libraries are installed in/ usr / local / lib / perlXX, XX is the version number.

Window installation Perl

Perl on the Window platform ActiveStatePerl and Strawberry Perl compiler.

The biggest difference ActiveState Perl and Strawberry Perl Strawberry Perl is a number which includes some modules from CPAN, so Strawberry Perl downloaded installation file has more than 80 M, and ActiveState Perl only 20M or so.

Here we used Strawberry Perl.

Perl installation steps on Window System as follows:

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

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

  • After downloading double click to open, according to the installation wizard step by step installation.

Mac OS install Perl

Mac OS systems are typically installed by default of Perl, if not installed perform the following steps:

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

  • Download for Mac OS source code package.

  • Do this after you downloadperl-5.xytar.gz file.

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

After the successful implementation of Perl installation path is/ usr / local / bin,libraries are installed in/ usr / local / lib / perlXX, XX is the version number.


Run Perl

Perl has a different implementation.

1 Interactive

We can execute perl code directly in command line syntax is as follows:

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

或 

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

Command line parameters are as follows:

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

Allow pollution detection

-t Allow pollution warning
-U Allow unsafe practices
-w Allow many useful warning
-W Allow all warnings
-X Use caution disabled
-e program Perl code execution
file Execute perl scripts

2, script execution

We can perl code in the script file, execute the following command file code:

$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 of the graphical user interface (GUI) environment. The following recommended two commonly used integrated development environment for Perl:

  • Padre : Padre is to provide a developer for the Perl language integrated development environment that provides syntax highlighting and code refactoring.

  • The EPIC : the EPIC is Perl Eclipse IDE plugin, if you are familiar with Eclipse, you can use it.

    Installation steps: Help -> Eclipse Marketplace -> Input EPIC -> you can choose to install and update.