Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. “Perl” refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned “sister language”, Perl 6, before the latter’s name was officially changed to Raku in October 2019.
Though Perl is not officially an acronym, there are various backronyms in use, including “Practical Extraction and Reporting Language”. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions. Raku, which began as a redesign of Perl 5 in 2000, eventually evolved into a separate language. Both languages continue to be developed independently by different development teams and liberally borrow ideas from each other.
The Perl languages borrow features from other programming languages including C, shell script (sh), AWK, and sed; Wall also alludes to BASIC and Lisp in the introduction to Learning Perl (Schwartz & Christiansen) and so on. They provide text processing facilities without the arbitrary data-length limits of many contemporary Unix command line tools, facilitating manipulation of text files. Perl 5 gained widespread popularity in the late 1990s as a CGI scripting language, in part due to its unsurpassed regular expression and string parsing abilities.
In addition to CGI, Perl 5 is used for system administration, network programming, finance, bioinformatics, and other applications, such as for GUIs. It has been nicknamed “the Swiss Army chainsaw of scripting languages” because of its flexibility and power, and also its ugliness. In 1998, it was also referred to as the “duct tape that holds the Internet together,” in reference to both its ubiquitous use as a glue language and its perceived inelegance.
Perl is a highly expressive programming language: source code for a given algorithm can be short and highly compressible.
Perl was originally named “Pearl”. Wall wanted to give the language a short name with positive connotations; he claims that he considered every three- and four-letter word in the dictionary. He also considered naming it after his wife Gloria. Wall discovered the existing PEARL programming language before Perl’s official release and changed the spelling of the name.
When referring to the language, the name is normally capitalized (Perl) as a proper noun. When referring to the interpreter program itself, the name is often uncapitalized (perl) because most Unix-like file systems are case-sensitive. Before the release of the first edition of Programming Perl, it was common to refer to the language as perl; Randal L. Schwartz, however, capitalized the language’s name in the book to make it stand out better when typeset. This case distinction was subsequently documented as canonical.[26]
The name is occasionally expanded as Practical Extraction and Report Language, but this is a backronym.[27] Other expansions have been suggested as equally canonical, including Wall’s own Pathologically Eclectic Rubbish Lister which is in the manual page for perl. Indeed, Wall claims that the name was intended to inspire many different expansions.
The overall structure of Perl derives broadly from C. Perl is procedural in nature, with variables, expressions, assignment statements, brace-delimited blocks, control structures, and subroutines.
Perl also takes features from shell programming. All variables are marked with leading sigils, which allow variables to be interpolated directly into strings. However, unlike the shell, Perl uses sigils on all accesses to variables, and unlike most other programming languages that use sigils, the sigil doesn’t denote the type of the variable but the type of the expression. So for example, while an array is denoted by the sigil “@” (for example @arrayname
), an individual member of the array is denoted by the scalar sigil “$” (for example $arrayname[3]
). Perl also has many built-in functions that provide tools often used in shell programming (although many of these tools are implemented by programs external to the shell) such as sorting, and calling operating system facilities.
Perl takes lists from Lisp, hashes (“associative arrays”) from AWK, and regular expressions from sed. These simplify and facilitate many parsing, text-handling, and data-management tasks. Also shared with Lisp are the implicit return of the last value in a block, and the fact that all statements have a value, and thus are also expressions and can be used in larger expressions themselves.
Perl 5 added features that support complex data structures, first-class functions (that is, closures as values), and an object-oriented programming model. These include references, packages, class-based method dispatch, and lexically scoped variables, along with compiler directives (for example, the strict
pragma). A major additional feature introduced with Perl 5 was the ability to package code as reusable modules. Wall later stated that “The whole intent of Perl 5’s module system was to encourage the growth of Perl culture rather than the Perl core.”
All versions of Perl do automatic data-typing and automatic memory management. The interpreter knows the type and storage requirements of every data object in the program; it allocates and frees storage for them as necessary using reference counting (so it cannot deallocate circular data structures without manual intervention). Legal type conversions — for example, conversions from number to string — are done automatically at run time; illegal type conversions are fatal errors.
Perl has many and varied applications, compounded by the availability of many standard and third-party modules.
Perl has chiefly been used to write CGI scripts: large projects written in Perl include cPanel, Slash, Bugzilla, RT, TWiki, and Movable Type; high-traffic websites that use Perl extensively include Priceline.com, Craigslist, IMDb, LiveJournal, DuckDuckGo, Slashdot and Ticketmaster. It is also an optional component of the popular LAMP technology stack for Web development, in lieu of PHP or Python. Perl is used extensively as a system programming language in the Debian GNU/Linux distribution.
Perl is often used as a glue language, tying together systems and interfaces that were not specifically designed to interoperate, and for “data munging,” that is, converting or processing large amounts of data for tasks such as creating reports. In fact, these strengths are intimately linked. The combination makes Perl a popular all-purpose language for system administrators, particularly because short programs, often called “one-liner programs,” can be entered and run on a single command line.
Perl code can be made portable across Windows and Unix; such code is often used by suppliers of software (both COTS and bespoke) to simplify packaging and maintenance of software build- and deployment-scripts.
Graphical user interfaces (GUIs) may be developed using Perl. For example, Perl/Tk and wxPerl are commonly used to enable user interaction with Perl scripts. Such interaction may be synchronous or asynchronous, using callbacks to update the GUI.
The above is a brief about Perl. Watch this space for more updates on the latest trends in Technology.