Perl environment installation
Before we can start learning the Perl language, we need to install the Perl execution environment.
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 a minute…
Perl is already installed by default on many system platforms, and we can check whether it is 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 you output the above information to indicate that it has been installed, if it is not already installed, you can see the following installation instructions.
Install Perl
We can download the installation package for the corresponding platform: https://www.perl.org/get.html on Perl’s official website.
Unix and Linux install Perl
The steps to install Perl on a Unix/Linux system are as follows:
Open it through a browser http://www.perl.org/get.html。
Download the source package for Unix/Linux.
Download
perl-5.x.y.tar.gz
to do the following after the file.
$ 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 see if the installation was successful.
After the installation is successful, the installation path of Perl is /usr/local/bin
, the library is installed in the /usr/local/lib/perlXX
, XX is the version number.
Window install 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 more than some modules in CPAN, so the installationfiles downloaded by Strawberry Perl are more than 80m, while ActiveState Perl is only about 20m.
We use Strawberry Perl here.
The steps to install Perl on a Window system are as follows:
Link to the Strawberry installation package: http://strawberryperl.com.
Download the version of your system: 32bit or 64bit.
After downloading, double-click to open it, and press the installation wizard to install it step by step.
Mac OS install Perl
Mac OS systems generally have Perl installed by default. If not, perform thefollowing steps:
Open it through a browser http://www.perl.org/get.html。
Download the source package for Mac OS.
Download
perl-5.x.y.tar.gz
to do the following after the file.
$ 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
, the library is installed in the /usr/local/lib/perlXX
, XX is the version number.
Run Perl
Perl can be executed in different ways.
1.Interactive
We can execute the perl code directly from the command line. The syntax format is as follows:
$perl -e <perl code> # Unix/Linux
or
C:>perl -e <perl code> # Windows/DOS
The command line parameters are as follows:
Option |
Description |
---|---|
|
Run the program in debug mode |
|
Specify the @ INC/#include directory |
|
Allow pollution detection |
|
Allow pollution warning |
|
Allow unsafe operations |
|
Allow a lot of useful warnings |
|
Allow all warnings |
|
Disable use warning |
|
Execute perl code |
|
Execute perl script file |
2.Script execution
We can put the perl code in a script file and execute the file code with thefollowing command:
$perl script.pl # Unix/Linux
or
C:>perl script.pl # Windows/DOS
IDE:Integrated Development Environment
We can also execute perl scripts on some graphical user interface (GUI) environments. The following two common Perl integrated development environments are recommended:
Padre Padre is an integrated development environment for Perl language developers, providing syntax highlighting and code refactoring.
EPIC EPIC is a plug-in for Perl Eclipse IDE. If you are familiar with Eclipse, you can use it.
Installation steps: Help– > Eclipse Marketplace– > enter EPIC– > Select install and update.