Perl explained


Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall, a linguist working as a systems administrator for NASA, in 1987, as a general purpose Unix scripting language to make report processing easier.Since then, it has undergone many changes and revisions and become widely popular among programmers. Larry Wall continues to oversee development of the core language, and its upcoming version, Perl 6.Perl borrows features from other programming languages including C, shell scripting (sh), AWK, and sed. The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools, facilitating easy manipulation of text files. It is also used for graphics programming, system administration, network programming, applications that require database access and CGI programming on the Web. Perl is nicknamed "the Swiss Army chainsaw of programming languages" due to its flexibility and adaptability.

History

Larry Wall began work on Perl in 1987, while working as a programmer at Unisys and released version 1.0 to the comp.sources.misc newsgroup on December 18, 1987. The language expanded rapidly over the next few years. Perl 2, released in 1988, featured a better regular expression engine. Perl 3, released in 1989, added support for binary data streams.Originally the only documentation for Perl was a single (increasingly lengthy) man page. In 1991, Programming perl (known to many Perl programmers as the "Camel Book") was published and became the de facto reference for the language. At the same time, the Perl version number was bumped to 4-not to mark a major change in the language but to identify the version that was documented by the book.Perl 4 went through a series of maintenance releases, culminating in Perl 4.036 in 1993. At that point, Wall abandoned Perl 4 to begin work on Perl 5.Initial design of Perl 5 continued into 1994. The perl5-porters mailing list was established in May 1994 to coordinate work on porting Perl 5 to different platforms. It remains the primary forum for development, maintenance, and porting of Perl 5.Perl 5 was released on October 17, 1994. It was a nearly complete rewrite of the interpreter, and it added many new features to the language, including objects, references, lexical variables and modules. Importantly, modules provided a mechanism for extending the language without modifying the interpreter. This allowed the core interpreter to stabilize, even as it enabled ordinary Perl programmers to add new language features.Perl 5 is still being actively maintained. Important features and some essential new language constructs-including Unicode support, threads, improved support for object-oriented programming, and many other enhancements-have been added along the way.On December 18, 2007, the 20th anniversary of Perl 1.0, Perl 5.10.0 was released. Perl 5.10.0 included notable new features, which brought it closer to Perl 6. Some of these new features were a new switch statement (called "given"/"when"), regular expressions updates, and the so-called smart match operator, "~~". In December 2008, Perl 5.8.9 was released.One of the most important events in Perl 5 history took place outside of the language proper and was a consequence of its module support. On October 26, 1995, the Comprehensive Perl Archive Network (CPAN) was established as a repository for Perl modules and Perl itself. At the time of writing, it carries more than 15,000 modules by more than 7,000 authors. CPAN is widely regarded as one of the greatest strengths of Perl in practice.

Name

Perl was originally named Pearl, after the Parable of the Pearl from the Gospel of Matthew. Larry Wall wanted to give the language a short name with positive connotations; he claims that he considered (and rejected) 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). When referring to the interpreter program itself, the name is often uncapitalized (perl) because 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, capitalised the language's name in the book to make it stand out better when typeset. This case distinction was subsequently documented as canonical.There is some contention about the all-caps spelling "PERL," which the documentation declares incorrect and which some core community members consider a sign of outsiders. Although the name is occasionally taken as an acronym for Practical Extraction and Report Language (which appears at the top of the documentation and in a lot of printed literature, this expansion actually came after the name; several others have been suggested as equally canonical, including Wall's own humorous Pathologically Eclectic Rubbish Lister. Indeed, Wall claims that the name was intended to inspire many different expansions.

The camel symbol

Programming Perl, published by O'Reilly Media, features a picture of a camel on the cover and is commonly referred to as The Camel Book. This image of a camel has become a general symbol of Perl. It is also a hacker emblem, appearing on some T-shirts and other clothing items.O'Reilly owns the image as a trademark but claims to use their legal rights only to protect the "integrity and impact of that symbol".O'Reilly allows non-commercial use of the symbol and provides Programming Republic of Perl logos and Powered by Perl buttons. However, the Camel has never been meant to be an official Perl symbol, and if one is to be considered instead, it's an onion.

Overview

Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, games, and GUI development.The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). Its major features include support for multiple programming paradigms (procedural, object-oriented, and functional styles), reference counting memory management (without a cycle-detecting garbage collector), built-in support for text processing, and a large collection of third-party modules.According to Larry Wall, Perl has two slogans. The first is "There's more than one way to do it," commonly known as TMTOWTDI. The second slogan is "Easy things should be easy and hard things should be possible."

Features

The overall structure of Perl derives broadly from C. Perl is procedural in nature, with variable, expressions, assignment statements, brace-delimited code blocks, control structures, and subroutines.Perl also takes features from shell programming. All variables are marked with leading sigils, which unambiguously identify the data type (for example, scalar, array, hash) of the variable in context. Importantly, sigils allow variables to be interpolated directly into strings. Perl 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 on system facilities.Perl takes lists from Lisp, associative arrays (hashes) from AWK, and regular expressions from sed. These simplify and facilitate many parsing, text-handling, and data-management tasks.In Perl 5, features were added 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. Larry 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 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.

Design

The design of Perl can be understood as a response to three broad trends in the computer industry: falling hardware costs, rising labor costs, and improvements in compiler technology. Many earlier computer languages, such as Fortran and C, were designed to make efficient use of expensive computer hardware. In contrast, Perl is designed to make efficient use of expensive computer programmers.Perl has many features that ease the programmer's task at the expense of greater CPU and memory requirements. These include automatic memory management; dynamic typing; strings, lists, and hashes; regular expressions; introspection; and an eval() function.Wall was trained as a linguist, and the design of Perl is very much informed by linguistic principles. Examples include Huffman coding (common constructions should be short), good end-weighting (the important information should come first), and a large collection of language primitives. Perl favors language constructs that are concise and natural for humans to read and write, even where they complicate the Perl interpreter.Perl syntax reflects the idea that "things that are different should look different." For example, scalars, arrays, and hashes have different leading sigils. Array indices and hash keys use different kinds of braces. Strings and regular expressions have different standard delimiters. This approach can be contrasted with languages such as Lisp, where the same S-expression construct and basic syntax are used for many different purposes.
Perl does not enforce any particular programming paradigm (procedural, object-oriented, functional, and others) or even require the programmer to choose among them.There is a broad practical bent to both the Perl language and the community and culture that surround it. The preface to Programming Perl begins, "Perl is a language for getting your job done." One consequence of this is that Perl is not a tidy language. It includes many features, tolerates exceptions to its rules, and employs heuristics to resolve syntactical ambiguities. Because of the forgiving nature of the compiler, bugs can sometimes be hard to find. Discussing the variant behaviour of built-in functions in list and scalar contexts, the perlfunc(1) manual page says, "In general, they do what you want, unless you want consistency."
In addition to Larry Wall's two slogans mentioned above, Perl has several mottos that convey aspects of its design and use, including "Perl: the Swiss Army Chainsaw of Programming Languages" and "No unnecessary limits". Perl has also been called "The Duct Tape of the Internet".No written specification or standard for the Perl language exists, and there are no plans to create one for the current version of Perl. There has been only one implementation of the interpreter, and the language has evolved along with it. That interpreter, together with its functional tests, stands as a de facto specification of the language.

Applications

Perl has many and varied applications, compounded by the availability of many standard and third-party modules.Perl has been used since the early days of the Web to write CGI scripts. It is known as one of "the three Ps" (along with Python and PHP), the most popular dynamic languages for writing Web applications. It is also an integral component of the popular LAMP solution stack for web development. Large projects written in Perl include Slash, Bugzilla, RT, TWiki, and Movable Type. Many high-traffic websites use Perl extensively. Examples include Amazon.com, bbc.co.uk, Booking.com (Priceline), Craigslist, IMDb, LiveJournal, Slashdot, Ticketmaster, Zappos.com and YouPorn.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 can be entered and run on a single command line.With a degree of care, Perl code can be made portable across Windows and Unix. Portable Perl 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 is commonly used to enable user interaction with Perl scripts. Such interaction may be synchronous or asynchronous using callbacks to update the GUI. For more information about the technologies involved, see Tk,Tcl, and WxPerl.
Perl is also widely used in finance, bioinformatics and geology, where it is valued for rapid application development and deployment and for its capability to handle large data sets.

Implementation

Perl is implemented as a core interpreter, written in C, together with a large collection of modules, written in Perl and C. The source distribution is, , 12 MB when packaged in a tar file and compressed. The interpreter is 150,000 lines of C code and compiles to a 1 MB executable on typical machine architectures. Alternatively, the interpreter can be compiled to a link library and embedded in other programs. There are nearly 500 modules in the distribution, comprising 200,000 lines of Perl and an additional 350,000 lines of C code. (Much of the C code in the modules consists of character-encoding tables.)The interpreter has an object-oriented architecture. All of the elements of the Perl language-scalars, arrays, hashes, coderefs, file handles-are represented in the interpreter by C structs. Operations on these structs are defined by a large collection of macros, typedefs, and functions; these constitute the Perl C API. The Perl API can be bewildering to the uninitiated, but its entry points follow a consistent naming scheme, which provides guidance to those who use it.Most of what happens in Perl's compile phase is compilation, and most of what happens in Perl's run phase is execution, but there are significant exceptions. Perl makes important use of its capability to execute Perl code during the compile phase. Perl will also delay compilation into the run phase. The terms that indicate the kind of processing that is actually occurring at any moment are compile time and run time. Perl is in compile time at most points during the compile phase, but compile time may also be entered during the run phase. The compile time for code in a string argument passed to the eval built-in occurs during the run phase. Perl is often in run time during the compile phase and spends most of the run phase in run time. Code in BEGIN blocks executes at run time but in the compile phase.At compile time, the interpreter parses Perl code into a syntax tree. At run time, it executes the program by walking the tree. Text is parsed only once, and the syntax tree is subject to optimization before it is executed, so that execution is relatively efficient. Compile-time optimizations on the syntax tree include constant folding and context propagation, but peephole optimization is also performed.Perl has a Turing-complete grammar because parsing can be affected by run-time code executed during the compile phase. Therefore, Perl cannot be parsed by a straight Lex/Yacc lexer/parser combination. Instead, the interpreter implements its own lexer, which coordinates with a modified GNU bison parser to resolve ambiguities in the language.It is often said that "Only perl can parse Perl", meaning that only the Perl interpreter (perl) can parse the Perl language (Perl), but even this is not, in general, true. Because the Perl interpreter can simulate a Turing machine during its compile phase, it would need to decide the Halting Problem in order to complete parsing in every case. It's a long-standing result that the Halting Problem is undecidable, and therefore not even Perl can always parse Perl. Perl makes the unusual choice of giving the user access to its full programming power in its own compile phase. The cost in terms of theoretical purity is high, but practical inconvenience seems to be rare.Perl is distributed with some 120,000 functional tests. These run as part of the normal build process and extensively exercise the interpreter and its core modules. Perl developers rely on the functional tests to ensure that changes to the interpreter do not introduce bugs; conversely, Perl users who see that the interpreter passes its functional tests on their system can have a high degree of confidence that it is working properly.Maintenance of the Perl interpreter has become increasingly difficult over the years. The code base has been in continuous development since 1994. The code has been optimized for performance at the expense of simplicity, clarity, and strong internal interfaces. New features have been added, yet virtually complete backward compatibility with earlier versions is maintained. The size and complexity of the interpreter is a barrier to developers who wish to work on it.

Availability

Perl is free software and is licensed under both the Artistic License and the GNU General Public License. Distributions are available for most operating systems. It is particularly prevalent on Unix and Unix-like systems, but it has been ported to most modern (and many obsolete) platforms. With only six reported exceptions, Perl can be compiled from source code on all Unix-like, POSIX-compliant, or otherwise-Unix-compatible platforms. However, this is rarely necessary, because Perl is included in the default installation of many popular operating systems.Because of unusual changes required for the Mac OS Classic environment, a special port called MacPerl was shipped independently.The Comprehensive Perl Archive Network carries a complete list of supported platforms with links to the distributions available on each CPAN/ports. CPAN is also the source for publicly available Perl modules that are not part of the core Perl distribution.

Windows

Users of Microsoft Windows typically install one of the native binary distributions of Perl for Win32, most commonly ActivePerl. Compiling Perl from source code under Windows is possible, but most installations lack the requisite C compiler and build tools. This also makes it difficult to install modules from the CPAN, particularly those that are partially written in C.Users of the ActivePerl binary distribution are, therefore, dependent on the repackaged modules provided in ActiveState's module repository, which are precompiled and can be installed with PPM. Limited resources to maintain this repository have been cause for various long-standing problems.Another popular way of running Perl under Windows is provided by the Cygwin emulation layer. Cygwin provides a Unix-like environment on Windows, and both perl and cpan are conveniently available as standard pre-compiled packages in the Cygwin setup program. Because Cygwin also includes the gcc, compiling Perl from source is also possible.


<-- Previous | Home Glossary | Next -->

📣 Latest tweets mentioning Perl


📖 Latest blogs mentioning Perl

host4geeks.com Icon 🏆 Alexa 191,095 - 📅 - WordPress Featured Image Not Showing Properly - WordPress is an incredibly versatile platform, but like any technology, it can encounter hiccups. One Read More

host4geeks.com Icon 🏆 Alexa 191,095 - 📅 - How to Fix “The Page May Not Render Properly Due to Resources Blocked” Error - In the world of the digital world, where information flows ceaselessly, encountering an error message Read More

nestify.io Icon 🏆 Alexa 40,899 - 📅 - How Paperless Business Forms are Reshaping the Processes? 8 Easy Steps To Create It - The concept of a paperless business form has gained significant traction as organizations seek to streamline processes, reduce environmental impact, and enhance efficiency. But what exactly is a paperless business form, and how does it revolutionize
tezhost.com Icon 🏆 Alexa 464,762 - 📅 - Ways to Fix WordPress Admin Dashboard not loading Properly issue - The WordPress Admin Dashboard serves as the command center for website management, offering a centralized space for content creation, customization, and monitoring. However, encountering issues where the dashboard fails to load properly can disrupt ...
redswitches.com Icon 🏆 Alexa 239,829 - 📅 - Perl vs Python: Showdown of the Best Programming Languages 2024 - In the dynamic and ever-evolving programming world, the debate between Perl vs Python is as relevant today as decades ago. Both languages, admired for their unique strengths and fervent communities, have carved distinct niches in the tech landscape.
web-hosting.net.my Icon 🏆 Alexa 185,129 - 📅 - TANDA-TANDA ANDA PERLU NAIK TARAF KE CLOUD SERVER - Keberkesanan laman web adalah kunci kepada kejayaan dalam talian dalam era digital yang pesat ini. Meningkatkan prestasi laman web anda dengan memindahkan kepada Cloud Server adalah salah satu keputusan yang paling kritikal. Jadi, bagaimanakah anda ...
shape.host Icon 🏆 Alexa 7,621,084 - 📅 - Efficient Ticketing System Setup: Installing OTRS on Alma Linux 8 - Are you looking for a reliable and efficient ticketing system for your help desk, call center, or IT service management team? Look no further than OTRS Community Edition. OTRS, which stands for “Open Source Trouble Ticket System,” is a free and ...

📋 Latest news about Perl

BuycPanel.com Has Gone Paperless - 📅 - In an effort to make their business more eco-friendly, cPanel provider BuycPanel.com now has a paperless office. They are headquartered in San Clemente, California and they are the largest provider for external cPanel distribution in the world. The company looks at this move as a very big step in their efforts to ...
Properly Optimizing WordPress Images for Google Image Search - 📅 - Images are worth 1,000 words and they are worth even more to a website. With the right optimization, you can get your images listed high on the Google Image Search. This can lead to plenty of traffic. Here are some of the ways you can properly optimize your WordPress images. Metadata in Dashboard When you upload an ...
FastNet Completes SuperLink Acquisition - 📅 - FastNet Corporation (fast.net), an Internet communications, consulting, Web hosting and colocation provider, announced the acquisition of SuperLink Internet Services (superlink.net), headquartered in East Brunswick, New Jersey. SuperLink currently offers service throughout the northeastern New Jersey region, ...
BT Loses Hyperlink Patent Case to Prodigy - 📅 - BT lost a controversial bid to sue Prodigy Communications, claiming one of BT's patents covered the use of hyperlinks, this week when a US District Judge awarded Prodigy its motion for summary judgment and dismissed the case, saying no jury could find that Prodigy infringes BT's patent. The ...
Hurricane Electric Holds Perl Seminar - 📅 - Web hosting and colocation provider Hurricane Electric (he.net) announced on Monday that it will host "Intermediate Perl," a second seminar in a two-part series on Perl Programming to be held on November 20, 2004 in Fremont, California. The event follows "Learning Perl," which took place a month ago. ...
HyperLink Launches Buy-a-Host.com - 📅 - Web development firm HyperLink Software announced on Tuesday that it has launched Buy-a-Host.com (buy-a-host.com), a free Web site that serves as an online marketplace for Web hosting providers that are interested in buying and selling hosting assets. HyperLink Software said the site is designed to ...
LogixBoxes Launches Perl - 📅 - Software and consultancy company LogicBoxes (logicboxes.com) announced on Thursday it has launched a Perl API kit for OrderBox ? its automation platform for ICANN accredited registrars and Web hosting companies. The Perl API kit allows LogicBoxes? clients and their resellers to register domain names, add domain ...