Getting started...LOGIN
Getting started with Perl
author:php.cn  update time:2022-04-14 16:05:12

Perl environment installation


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

  • Wait...

Perl has been installed by default on many system platforms. We can check whether it has been installed by using 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 output The above information indicates that it has been installed. If it has not been installed yet, you can see the following installation instructions.


Installing Perl

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

255B300D-DEE7-4F1B-9C61-54779C0288DA.jpg

Installing Perl on Unix and Linux

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

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

  • Download the source package for Unix/Linux.

  • After downloading the perl-5.x.y.tar.gz 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 we run the perl -v command to see if the installation is successful.

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

Window Installation Perl

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

The biggest difference between ActiveState Perl and Strawberry Perl is that Strawberry Perl contains many modules from CPAN, so the installation file downloaded by Strawberry Perl is more than 80M, while ActiveState Perl is only about 20M.

We use Strawberry Perl here.

The steps to install Perl on Window 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 to install it.

080-sp-install-07-finish.png

Mac OS Install Perl

Mac OS system generally has Perl installed by default. If it is not installed, perform the following steps:

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

  • Download the source code package for Mac OS.

  • After downloading the perl-5.x.y.tar.gz 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 installation path of Perl is /usr/local/bin, and the library is installed in /usr/local/lib/perlXX, XX is the version number.


Running Perl

Perl has different execution methods.

1. Interactive

We can execute perl code directly in the command line. The syntax format is as follows:

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

或 

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

The command line parameters are as follows:

OptionsDescription
-d[:debugger]Run the program in debug mode
-IdirectorySpecify @INC/#include directory
-T

Allow pollution Detection

-tallow pollution warning
-Uallow unsafe Action
-wAllow many useful warnings
-WAllow all warnings
-XDisable usage warning
-e programExecute perl code
fileExecute perl script file

2. Script execution

We can put the perl code in In the script file, execute the file code through 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 on some graphical user interface (GUI) environments script. The following are two commonly used Perl integrated development environments recommended:

  • Padre: Padre is an integrated development environment for Perl language developers, providing syntax highlighting and code refactoring functions.

  • 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.

    20150311184626567.png


#

php.cn