Perl is a general-purpose, high level interpreted and dynamic programming language. It was developed by Larry Wall, in 1987. There is no official Full form of the Perl, but still, the most used expansion is “Practical Extraction and Reporting Language“. Some of the programmers also refer Perl as the “Pathologically Eclectic Rubbish Lister” Or “Practically Everything Really Likable“. The acronym “Practical Extraction and Reporting Language” is used widely because Perl was originally developed for the text processing like extracting the required information from a specified text file and for converting the text file into a different form.
Evolution of Perl:
It all started when Larry Wall was working on a task to generate the reports from a lot of text files which have cross-references. Then he started to use awk for this task but soon he found that it is not sufficient for this task. So instead of writing a utility for this task, he wrote a new language i.e. Perl and also wrote the interpreter for it. He wrote the language Perl in C and some of the concepts are taken from awk, sed, and LISP etc. At the beginning level, Perl was developed only for the system management and text handling but in later versions, Perl got the ability to handle regular expressions, and network sockets etc. In present Perl is popular for its ability to handling the Regex(Regular Expressions). The first version of Perl was 1.0 which released on December 18, 1987. The latest version of Perl is 5.28. Perl 6 is different from Perl 5 because it is a fully object-oriented reimplementation of Perl 5.
Perl has many reasons for being popular and in demand. Few of the reasons are mentioned below:
- Easy to start: Perl is a high-level language so it is closer to other popular programming languages like C, C++ and thus, becomes easy to learn for anyone.
- Text-Processing: As the acronym “Practical Extraction and Reporting Language” suggest that Perl has the high text manipulation abilities by which it can generate reports from different text files easily. Also, it can convert the files into some another form.
- Contained best Features: Perl contains the features of different languages like C, sed, awk, and sh etc. which makes the Perl more useful and productive.
- System Administration: Due to having the different scripting languages capabilities Perl make the task of system administration very easy. Instead of becoming dependent on many languages, just use Perl to complete out the whole task of system administration. In Spite of this Perl also used in web programming, web automation, GUI programming etc.
- Web and Perl: Perl can be embedded into web servers to increase its processing power and it has the DBI package, which makes web-database integration very easy.
Beginning with Perl Programming:
- Finding a Interpreter: There are various online IDEs which can be used to run Perl programs without installing.
- Windows: There are various IDEs to run Perl programs or scripts: Padre, Eclipse with EPIC plugin etc.
Programming in Perl
Since the Perl is a lot similar to other widely used languages syntactically, it is easier to code and learn in Perl. Programs can be written in Perl in any of the widely used text editors like Notepad++, gedit etc. After writing the program save the file with the extension .pl or .PL To run the program use perl file_name.pl on the command line.
Example: A simple program to print Welcome to GFG!
Welcome to GFG!
Comments: Comments are used for enhancing the readability of the code. The interpreter will ignore the comment entries and does not execute them. Comments can be of the single line or multiple lines.
- Single line Comment:
# Single line comment
- Multi-line comment:
= Multi line comments Line start from = is interpreted as the starting of multiline comment and =cut is consider as the end of multiline comment =cut
print: It is a function in Perl to show the result or any specified output on the console.
Quotes: In Perl, you can use either single quotes(‘’)or double quotes(“”). Using single quotes will not interpolate any variable or special character but using double quotes will interpolates.
\n: It is used for the new line character which uses the backslash (\) character to escape any type of character.
/usr/bin/perl: It is actual Perl interpreter binary which always starts with #!. This is used in the Perl Script Mode Programming.
Note: Perl is case sensitive programming language and that’s why $Geeks and $geeks are two different identifiers.
Advantages of Perl:
- Perl Provides supports for cross platform and it is compatible with mark-up languages like HTML, XML etc.
- It is very efficient in text-manipulation i.e. Regular Expression. It also provides the socket capability.
- It is free and a Open Source software which is licensed under Artistic and GNU General Public License (GPL).
- It is an embeddable language that’s why it can embed in web servers and database servers.
- It supports more than 25, 000 open source modules on CPAN(Comprehensive Perl Archive Network) which provide many powerful extensions to the standard library. For example, XML processing, GUI(Graphical User Interface) and DI(Database Integration) etc.
Disadvantages of Perl:
- Perl doesn’t supports portability due to CPAN modules.
- Programs runs slowly and program needs to be interpreted each time when any changes are made.
- In Perl, the same result can be achieved in several different ways which make the code untidy as well as unreadable.
- Usability factor is lower when compared to other languages.
- One of the major application of Perl language is to processing of text files and analysis of the strings.
- Perl also used for CGI( Common Gateway Interface) scripts.
- Used in web development, GUI(Graphical User Interface) development.
- Perl’s text-handling capabilities is also used for generating SQL queries.
- Perl | File Handling Introduction
- Perl Tutorial - Learn Perl With Examples
- Perl | Basic Syntax of a Perl Program
- Perl vs C/C++
- Perl | ord() Function
- Barewords in Perl
- Perl | my keyword
- while loop in Perl
- Perl | qq operator
- Perl | Operators | Set - 1
- Perl vs Java
- Perl | oct() Function
- Perl | log() Function
- Perl | Operators | Set - 2
- Perl | CGI Security
- Perl | Variables
- Perl | qw Operator
- What is the difference between Perl and PHP ?
- Perl | lt operator
- Perl | q operator
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.