Revision as of 05:07, 10 May 2006 edit-Barry- (talk | contribs)1,472 edits →Con: quotes from http://colabti.de/irclogger/irclogger_log/perl6?date=2006-05-10,Wed← Previous edit | Latest revision as of 04:13, 24 November 2024 edit undoKomonzia (talk | contribs)Extended confirmed users971 edits →Community: the comma here was removed in a copyedit on 29 June 2016 but it's meant to be there - as cited, the original JAPH scripts included the comma at the end. | ||
Line 1: | Line 1: | ||
{{Short description|Interpreted programming language first released in 1987}} | |||
{{otheruses}} | |||
{{Other uses|Perl (disambiguation)}} {{distinguish|PEARL (programming language)}} | |||
{{Use mdy dates|date=September 2014}} | |||
{{Infobox programming language | {{Infobox programming language | ||
|name = Perl | | name = Perl | ||
| logo = Perl language logo.svg | |||
|logo = <br>] | |||
| paradigm = ] | |||
|paradigm = ], ], ] | |||
| designer = ] | |||
|year = 1987 | |||
| |
| developer = Larry Wall | ||
| typing = Dynamic | |||
|developer = | |||
| influenced = ],{{citation needed|date=January 2016}} ],{{citation needed|date=February 2016}} ], ], ], ], ], ], ], ] | |||
|latest_release_version = 5.8.8 | |||
| license = ] 1.0<ref name="artistic-1.0"/><ref name="artistic-1.0-git"/> or ] version 1 or any later version<ref name="licensing"/> | |||
|latest_release_date = ], ] | |||
| website = {{url|https://www.perl.org/|perl.org}} | |||
|typing = dynamic | |||
| wikibooks = Perl Programming | |||
|implementations = | |||
| released = {{Start date and age|1987|12|18}}<ref name="perltimeline"/> | |||
|dialects = | |||
| latest release version = {{Unbulleted list | |||
|influenced_by = ], ], ], ], ] | |||
|influenced = ], ], ] | |||
|operating_system = ] | |||
|license =] or ] | |||
|website = | |||
}} | |||
'''Perl''', also '''Practical Extraction and Report Language''' (a ], see ]) is a ] procedural programming language designed by ] and first released in 1987. Perl borrows features from ], ] scripting (]), ], ], ], and, to a lesser extent, many other programming languages. | |||
|5.40.0<ref>{{cite web |url=https://www.nntp.perl.org/group/perl.perl5.porters/2024/06/msg268252.html |title=Perl v5.40.0 is now available |access-date=2024-06-11 |publisher=www.nntp.perl.org}}</ref> / {{Start date and age|mf=yes|2024|06|09|df=yes}} | |||
==Overview== | |||
|5.38.2<ref>{{cite web |url=https://www.nntp.perl.org/group/perl.perl5.porters/2023/11/msg267400.html |title=Perl 5.34.3, Perl 5.36.3 and Perl 5.38.2 are now available |access-date=2023-12-05 |publisher=www.nntp.perl.org}}</ref> / {{Start date and age|mf=yes|2023|11|29|df=yes}} | |||
The perlintro(1) ] <!-- sic. 'man' is short for 'manual' --> states: | |||
}} | |||
: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, GUI development, and more. | |||
| latest preview version=5.41.3<ref>{{cite web|url=https://www.nntp.perl.org/group/perl.perl5.porters/2024/08/msg268756.html |title=Release announcement for perl v5.41.3 |access-date=2024-08-29 |publisher=www.nntp.perl.org}}</ref> / {{Start date and age|2024|08|29|df=yes}} | |||
:The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). Its major features are that it's easy to use, supports both procedural and ] (OO) programming, has powerful built-in support for text processing, and has a large collection of third-party modules. | |||
| latest preview date=<!-- ;<br/> alpha-02 of {{nowrap|Perl 7}}<ref>{{Cite web|title=Releases · atoomic/perl|url=https://github.com/atoomic/perl/releases|access-date=2021-02-05|website=GitHub|language=en|archive-date=September 7, 2020|archive-url=https://web.archive.org/web/20200907173355/https://github.com/atoomic/perl/releases|url-status=live}}</ref><ref>{{Cite web|title=Announcing Perl 7 - nntp.perl.org|url=https://www.nntp.perl.org/group/perl.perl5.porters/2020/06/msg257565.html|last1=X|first1=Sawyer|date=June 24, 2020|quote=We intend to release 7.0.0 within a year. However, I am setting the goal of releasing it before the end of this year .|access-date=2021-02-05|website=www.nntp.perl.org|archive-date=November 25, 2020|archive-url=https://web.archive.org/web/20201125230437/https://www.nntp.perl.org/group/perl.perl5.porters/2020/06/msg257565.html|url-status=live}}</ref> / {{Start date and age|2020|09|24|mf=yes}} --> | |||
===Language features=== | |||
| influenced by=], ], ], ], ], ], ]<ref>{{cite web|title=Programming is Hard, Let's Go Scripting...|last1=Wall|first1=Larry|author1-link=Larry Wall|date=December 12, 2007|url=https://www.perl.com/pub/2007/12/06/soto-11.html/|quote=All language designers have their occasional idiosyncracies. I’m just better at it than most.|access-date=April 14, 2019|archive-date=July 28, 2017|archive-url=https://web.archive.org/web/20170728023959/http://www.perl.com/pub/2007/12/06/soto-11.html|url-status=live}}</ref> | |||
The overall structure of Perl derives broadly from the programming language ]. Perl is a ], with ]s, ]s, ]s, ]-delimited ]s, ]s, and ]s. | |||
| programming language=] | |||
| operating system=] | |||
| file ext=.plx, .pls, .pl, .pm, .xs, .t, .pod, .cgi, .psgi | |||
}} | |||
'''Perl''' is a ], ], ], ]. Though Perl is not officially an acronym,<ref>{{cite web |url=http://learn.perl.org/faq/perlfaq1.html#Whats-the-difference-between-perl-and-Perl |title=General Questions About Perl |last=Lapworth |first=Leo |publisher=Perl.org |work=Perl FAQ |access-date=February 24, 2012 |archive-date=May 28, 2013 |archive-url=https://web.archive.org/web/20130528001715/http://learn.perl.org/faq/perlfaq1.html#Whats-the-difference-between-perl-and-Perl |url-status=live}}</ref> there are various ]s in use, including "Practical Extraction and Reporting Language".<ref>{{cite web |url=http://linux.die.net/man/1/perl |title=perl(1): Practical Extraction/Report Language - Linux man page |publisher=Linux.die.net |access-date=2013-07-23 |archive-date=June 3, 2013 |archive-url=https://web.archive.org/web/20130603152544/http://linux.die.net/man/1/perl |url-status=live}}</ref> | |||
Perl also takes features from ]. All variables are marked with leading ]s. Sigils unambiguously identify variable names, allowing Perl to have a rich syntax. Importantly, sigils allow variables to be interpolated directly into strings. Like the Unix shells, Perl has many built-in functions for common tasks, like sorting, and for accessing system facilities. | |||
Perl was developed by ] in 1987<ref name="long"/> as a general-purpose ] ] to make report processing easier.<ref name="sheppard00">{{cite web |url=http://www.perl.com/pub/2000/10/begperl1.html |title=Beginner's Introduction to Perl |last=Sheppard |first=Doug |date=2000-10-16 |publisher=dev.perl.org |access-date=2011-01-08 |archive-date=June 5, 2011 |archive-url=https://web.archive.org/web/20110605130400/http://www.perl.com/pub/2000/10/begperl1.html |url-status=live}}</ref><ref name="long"/><ref name=":0">{{Cite web |title=Larry Wall, the Guru of Perl |url=https://www.linuxjournal.com/article/3394 |access-date=2023-08-30 |website=Linux Journal}}</ref> Since then, it has undergone many changes and revisions. Perl originally was not capitalized and the name was changed to being capitalized by the time Perl 4 was released.<ref name=":0"/> The latest release is Perl 5, first released in 1994. From 2000 to October 2019 a sixth version of Perl was in development; the sixth version's name was changed to ].<ref>{{cite web |url=https://www.perl.org/about.html |title=About Perl |publisher=perl.org |quote="Perl" is a family of languages, "Perl 6" is part of the family, but it is a separate language that has its own development team. Its existence has no significant impact on the continuing development of "Perl 5". |access-date=2013-04-20 |archive-date=November 6, 2015 |archive-url=https://web.archive.org/web/20151106051931/https://www.perl.org/about.html |url-status=live}}</ref><ref>{{cite web |url=https://github.com/Raku/problem-solving/blob/master/solutions/language/Path-to-Raku.md |title=Path to Raku |publisher=GitHub |quote=This document describes the steps to be taken to effectuate a rename of Perl 6 to Raku |access-date=2021-01-14 |archive-date=November 12, 2020 |archive-url=https://web.archive.org/web/20201112035821/https://github.com/Raku/problem-solving/blob/master/solutions/language/Path-to-Raku.md |url-status=live}}</ref> Both languages continue to be developed independently by different development teams which liberally borrow ideas from each other. | |||
Perl takes ]s from ], ]s from ], and ] from ]. These simplify and facilitate all manner of parsing, text handling, and data management tasks. | |||
Perl borrows features from other programming languages including ], ], ], and ].<ref name="perltimeline">{{cite web |url=http://history.perl.org/PerlTimeline.html |title=The Timeline of Perl and its Culture (v3.0_0505) |last1=Ashton |first1=Elaine |year=1999 |access-date=March 12, 2004 |archive-date=January 11, 2013 |archive-url=https://web.archive.org/web/20130111100906/http://history.perl.org/PerlTimeline.html |url-status=live}}</ref> It provides text processing facilities without the arbitrary data-length limits of many contemporary ].<ref name="programmingperl2">{{cite book |title=Programming Perl, Third Edition |date=July 2000 |publisher=] |isbn=978-0-596-00027-1 |last1=Wall|first1=Larry|author-link1=Larry Wall|last2= Christiansen|first2=Tom|last3=Orwant|first3=Jon}}</ref> Perl is a highly ] programming language: source code for a given algorithm can be short and highly compressible.<ref>{{Cite web|title=How programs are measured |url=https://benchmarksgame-team.pages.debian.net/benchmarksgame/how-programs-are-measured.html#source-code|access-date=2020-10-05|website=Computer Language Benchmarks Game, Debian.net|archive-date=July 12, 2020|archive-url=https://web.archive.org/web/20200712000728/https://benchmarksgame-team.pages.debian.net/benchmarksgame/how-programs-are-measured.html#source-code|url-status=live}}</ref><ref>{{Cite web|title=RSA in 3 lines of perl - Everything2.com|url=https://everything2.com/title/RSA+in+3+lines+of+perl|access-date=2020-10-05|website=everything2.com|archive-date=October 8, 2020|archive-url=https://web.archive.org/web/20201008120935/https://everything2.com/title/RSA+in+3+lines+of+perl|url-status=live}}</ref> | |||
In Perl 5, features were added that support complex ]s, ]s (i.e. ] as values), and an ] model. These include ]s, packages, and class-based method dispatch. Perl 5 also saw the introduction of ], which make it easier to write robust code, and modules, which make it practical to write and distribute libraries of Perl code. | |||
Perl gained widespread popularity in the mid-1990s as a ] language, in part due to its powerful ] and ] ] abilities.<ref>{{cite web |url=http://www.catb.org/esr/writings/taoup/html/ch14s04.html#perl |title=Language Evaluations |quote=Perl's strongest point is its extremely powerful built-in facilities for pattern-directed processing of textual, line-oriented data formats; it is unsurpassed at this. |access-date=January 30, 2015 |archive-date=March 10, 2015 |archive-url=https://web.archive.org/web/20150310123855/http://www.catb.org/esr/writings/taoup/html/ch14s04.html#perl |url-status=live}}</ref><ref>{{cite web |url=http://www.cio.com/article/2437271/developer/you-used-perl-to-write-what--.html |title=You Used Perl to Write WHAT?! |date=January 24, 2008 |quote=perl has always been the go-to language for any task that involves pattern-matching input |access-date=February 4, 2015 |archive-date=February 4, 2015 |archive-url=https://web.archive.org/web/20150204175543/http://www.cio.com/article/2437271/developer/you-used-perl-to-write-what--.html |url-status=live}}</ref><ref>{{cite web |url=http://archive.oreilly.com/pub/a/oreilly/perl/news/importance_0498.html |title=The Importance of Perl |quote=Perl's unparalleled ability to process text... |access-date=February 4, 2015 |archive-url=https://web.archive.org/web/20150202010003/http://archive.oreilly.com/pub/a/oreilly/perl/news/importance_0498.html |archive-date=February 2, 2015 |url-status=dead |df=mdy-all}}</ref><ref name="roderick02">{{cite book |title=Advanced Linux Networking |url=https://archive.org/details/linux00libg_999 |url-access=limited |date=June 21, 2002 |publisher=Addison-Wesley Professional |isbn=978-0-201-77423-8 |page= |last1=Smith |first1=Roderick W.}}</ref> In addition to CGI, Perl 5 is used for ], ], finance, ], and other applications, such as for ]s (GUIs). It has been nicknamed "the Swiss Army chainsaw<!-- WARNING: This should read *chainsaw*, not knife. See the reference. --> of scripting languages" because of its flexibility and power.<ref>{{cite web |url=http://www.perl.com/pub/a/2000/10/begperl1.html |title=Beginner's Introduction to Perl |last=Sheppard |first=Doug |date=2000-10-16 |publisher=] |access-date=2008-07-27 |archive-date=June 4, 2008 |archive-url=https://web.archive.org/web/20080604140740/http://www.perl.com/pub/a/2000/10/begperl1.html |url-status=live}}</ref> In 1998, it was also referred to as the "] that holds the ] together", in reference to both its ubiquitous use as a ] and its perceived inelegance.<ref name="leonard98">{{cite news |url=http://www.salon.com/1998/10/13/feature_269/ |title=The joy of Perl |last=Leonard |first=Andrew |work=] |access-date=2012-06-05 |archive-date=July 6, 2012 |archive-url=https://web.archive.org/web/20120706094345/http://www.salon.com/1998/10/13/feature_269/ |url-status=live}}</ref> | |||
All versions of Perl do automatic data typing and ]. The interpreter knows the type and storage requirements of every data object in the program; it allocates and frees storage for them as necessary. Legal type conversions are done automatically at run time; illegal type conversions are fatal errors. | |||
== Name and logos == | |||
===Applications=== | |||
{{ multiple image|total_width=400 | |||
Perl has many and varied applications. | |||
| image1=Perl-camel-small.png | |||
| caption1=The Camel symbol used by O'Reilly Media | |||
| image2=Perl onion symbol.svg | |||
| caption2=The onion logo used by The Perl Foundation | |||
}} | |||
Perl was originally named "Pearl". Wall wanted to give the language a short name with positive connotations. It is also a Christian reference to the ] from the Gospel of Matthew.<ref name="long"/><ref>{{Cite magazine |date=2016-03-07 |title=Scripting on the Lido Deck |url=https://www.wired.com/2000/10/cruise/ |access-date=2023-02-14 |magazine=Wired|archive-url=https://web.archive.org/web/20160307004219/https://www.wired.com/2000/10/cruise/ |archive-date=March 7, 2016}}</ref> However, Wall discovered the existing ] language before Perl's official release and dropped the "a" from the name.<ref name="richardson1999">{{cite journal|last=Richardson|first=Marjorie|date=1999-05-01|title=Larry Wall, the Guru of Perl|url=http://www.linuxjournal.com/article/3394|url-status=live|journal=]|archive-url=https://web.archive.org/web/20130720013904/http://www.linuxjournal.com/article/3394|archive-date=July 20, 2013|access-date=2011-01-03}}</ref><ref name="long"/> | |||
It has been used since the early days of the Web to write ] scripts, and is an integral component of the popular ] (] / ] / ] / Perl, ], and ]) platform for web development. Large projects written in Perl include ], , and ], the ] software used in ] until 2002. It's known as one of "the three Ps" (Perl, ], and ]), which are the most popular server-side, open source scripting languages for the Web, though open source ] and ] implementations as well as ] have grown popular in recent years. | |||
The name is occasionally expanded as a ]: ''Practical Extraction and Report Language''<ref>{{cite book|last1=Schwartz|first1=Randal|url=https://archive.org/details/learningperl00schw_278|title=Learning Perl|last2=foy|first2=brian|last3=Phoenix|first3=Tom|date=June 16, 2011|publisher=O'Reilly Media, Inc.|isbn=978-1449313142|page=|quote=Perl is sometimes called the "Practical Extraction and Report Language", although it has also been called a "Pathologically Eclectic Rubbish Lister", among other expansions. It's actually a backronym, not an acronym, since Larry Wall, Perl's creator, came up with the name first and the expansion later. That's why 'Perl' isn't in all caps. There's no point in arguing that expansion is correct: Larry endorses both.|author-link1=Randal Schwartz|author-link2=brian d foy|url-access=limited}}</ref> and Wall's own ''Pathologically Eclectic Rubbish Lister'', which is in the ] for perl.<ref>{{cite web|last=Wall|first=Larry|author-link=Larry Wall|title=perl - The Perl language interpreter|url=http://perldoc.perl.org/perl.html#BUGS|url-status=live|archive-url=https://web.archive.org/web/20130701050810/http://perldoc.perl.org/perl.html#BUGS|archive-date=July 1, 2013|access-date=2011-01-26|work=Perl 5 version 12.2 documentation}}</ref> | |||
Perl is often used as a "]", tying together systems and interfaces that were not specifically designed to interoperate. Systems administrators use Perl as an all-purpose tool; short Perl programs can be entered and run on a single command line. | |||
''Programming Perl'', published by ], features a picture of a ] on the cover and is commonly called the "Camel Book".<ref name="schwartz01">{{cite book |last1=Schwartz |first1=Randal L |author-link1=Randal L. Schwartz |last2=Phoenix |first2=Tom |last3=Foy |first3=Brian |author-link3=Brian D Foy |title=Learning Perl, Third Edition |isbn=978-0-596-00132-2 |date=2007-12-06 |publisher=O'Reilly Media |url=https://archive.org/details/learningperl00schw}}</ref> This image has become an unofficial symbol of Perl. O'Reilly owns the image as a ] but licenses it for ] use, requiring only an acknowledgement and a link to www.perl.com. Licensing for commercial use is decided on a case-by-case basis.<ref name="camel">{{cite web |url=http://archive.oreilly.com/pub/a/oreilly/perl/usage |archive-url=https://web.archive.org/web/20180425080044/http://archive.oreilly.com/pub/a/oreilly/perl/usage |url-status=dead |archive-date=2018-04-25 |title=The Perl Camel Usage and Trademark Information |access-date=2011-01-09 |publisher=]}}</ref> O'Reilly also provides "Programming Republic of Perl" logos for non-commercial sites and "Powered by Perl" buttons for any site that uses Perl.<ref name="camel"/> | |||
Perl is widely used in finance and ], where it is valued for rapid application development, ability to handle large data sets, and the availability of many standard and third-party modules. | |||
] owns an alternative symbol, an onion, which it licenses to its subsidiaries, ], ], Perl.org, and others.<ref name="onion">{{cite web |url=http://www.perlfoundation.org/perl_trademark |title=Perl Trademark |access-date=2011-01-09 |publisher=] |archive-url=https://web.archive.org/web/20110503211915/http://www.perlfoundation.org/perl_trademark |archive-date=May 3, 2011 |url-status=dead |df=mdy-all}}</ref> The symbol is a ] on ].<ref name="gillmore98">{{cite news |first=Dan |last=Gillmore |title=Republic Of Perl |date=1998-10-25 |url=https://www.chicagotribune.com/1998/10/25/republic-of-perl/ |work=Chicago Tribune |access-date=2011-01-10 |archive-date=April 30, 2011 |archive-url=https://web.archive.org/web/20110430031425/http://articles.chicagotribune.com/1998-10-25/news/9810250094_1_programmers-open-source-movement-programming-community |url-status=live}}</ref> | |||
===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, as of 2005, 12 ] when packaged in a ] and ]. 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. | |||
== History == | |||
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. | |||
=== Early versions === | |||
The execution of a Perl program divides broadly into two phases: compile-time and run-time. At compile time, the interpreter parses the program text into a syntax tree. At run time, it executes the program by walking the tree. The text is parsed only once, and the syntax tree is subject to optimization before it is executed, so the execution phase is relatively efficient. Compile-time optimizations on the syntax tree include ], context propagation, and ]. | |||
] began work on Perl in 1987, while employed as a programmer at ];<ref name="programmingperl2"/> he released version 1.0 on December 18, 1987.<ref name="perltimeline"/><ref name="long">{{Cite magazine |last=Long |first=Tony |title=Dec. 18, 1987: Perl Simplifies the Labyrinth That Is Programming Language |language=en-US |magazine=Wired |url=https://www.wired.com/2007/12/dec-18-1987-perl-simplifies-the-labyrinth-that-is-programming-language/ |access-date=2023-02-14 |issn=1059-1028}}</ref> Wall based early ''Perl'' on some methods existing languages used for text manipulation.<ref name="long"/> | |||
Perl is a ] and has a context-sensitive ] that cannot be parsed by a straight ]/] lexer/parser combination. Instead, it implements its own lexer, which coordinates with a modified ] parser to resolve ambiguities in the language. It is said that "only perl can parse Perl", meaning that only the ] (''perl'') can parse the Perl language (''Perl''). The truth of this is attested to by the persistent imperfections of other programs that undertake to parse Perl, such as source code analyzers and auto-indenters. | |||
Perl 2, released in June 1988,<ref name="Kalita ">{{Cite book |last=Kalita |first=Jugal |url=https://books.google.com/books?id=aMuuTttVDcIC |title=On Perl: Perl for Students and Professionals |date=December 2003 |publisher=Universal-Publishers |isbn=978-1-58112-550-4 |language=en}}</ref><ref>{{Cite web |title=Perl Culture |url=https://docstore.mik.ua/orelly/perl/prog3/ch27_01.htm |access-date=2023-03-16 |website=docstore.mik.ua |language=en-US}}</ref> featured a better regular expression engine. Perl 3, released in October 1989,<ref name="Kalita "/> added support for ] streams.<ref>{{Cite web |last=Holloway |first=Ruth |title=Perl turns 30 and its community continues to thrive |url=https://opensource.com/article/17/10/perl-turns-30 |access-date=2023-06-23 |website=Opensource.com |language=en}}</ref> | |||
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 backwards compatibility with earlier versions is maintained. The size and complexity of the interpreter is a barrier to developers who wish to work on it. | |||
=== 1990s === | |||
Perl is distributed with some 90,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 the interpreter pass its functional tests on their system can have a high degree of confidence that it is working properly. | |||
{{Main|Perl 5 version history}} | |||
Originally, the only documentation for Perl was a single lengthy ]. In 1991, ''Programming Perl'', known to many Perl programmers as the "Camel Book" because of its cover, was published and became the ''de facto'' reference for the language.<ref>{{Cite web |title=Programming Perl, 3rd Edition |url=https://www.oreilly.com/library/view/programming-perl-3rd/0596000278/ |access-date=2023-04-11 |website=www.oreilly.com |language=en}}</ref> 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 well documented by the book.<ref>{{Cite web |title=perlhist - the Perl history records - Perldoc Browser |url=https://perldoc.perl.org/perlhist |access-date=2023-07-28 |website=perldoc.perl.org}}</ref> Perl 4 was released in March 1991.<ref name="Kalita"/> | |||
There is no written specification or standard for the Perl language, and no plans to create one for the current version of Perl. There has only ever been one implementation of the interpreter. That interpreter, together with its functional tests, stands as a de facto specification of the language. | |||
Perl 4 went through a series of ]s, culminating in Perl 4.036 in 1993, whereupon Wall abandoned Perl 4 to begin work on Perl 5. Initial design of Perl 5 continued into 1994. The ''perl5-porters'' ] 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.<ref>{{Cite web |url=http://www.nntp.perl.org/group/perl.perl5.porters/ |title=perl.perl5.porters archive |access-date=2011-01-13 |publisher=perl.org |archive-date=May 1, 2011 |archive-url=https://web.archive.org/web/20110501081803/http://www.nntp.perl.org/group/perl.perl5.porters/ |url-status=live}}</ref> | |||
===Availability=== | |||
Perl is ], and is licensed under both the ] and the ]. It is available for most ]s. It is particularly prevalent on ] and ] systems (such as ], ], and ]), and is growing in popularity on ] systems. | |||
Perl 5.000 was released on October 17, 1994.<ref name="perlhist">{{Cite web |url=http://perldoc.perl.org/perlhist.html |title=perlhist: the Perl history records |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=January 13, 2011 |archive-url=https://web.archive.org/web/20110113030100/http://perldoc.perl.org/perlhist.html |url-status=live}}</ref> It was a nearly complete rewrite of the ], and it added many new features to the language, including ], ], ], and ]. 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 has been in active development since then. | |||
Perl has been ported to over a hundred different platforms, and can, with only six reported exceptions, be compiled from ] on all Unix-like, ]-compliant or otherwise Unix-compatible platforms, including ], ], ], and ] (See ). A special port, , is available for ]. | |||
Perl 5.001 was released on March 13, 1995. Perl 5.002 was released on February 29, 1996 with the new prototypes feature. This allowed module authors to make ]s that behaved like Perl ]. Perl 5.003 was released June 25, 1996, as a security release.<ref>{{Cite web |title=Perl: Definition, History, & Facts |url=https://www.britannica.com/technology/Perl |access-date=2022-06-15 |website=Britannica.com |language=en}}</ref> | |||
Perl can be compiled from source on Windows, however many Windows installations lack a C compiler, so Windows users typically install a binary distribution, such as or . Users without a C compiler are also limited to pure Perl modules if they wish to add to the module library that comes with Perl. There's free software that can enable these users to install C modules, however it tends to be poorly documented, especially for beginners. | |||
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 ] (CPAN) was established as a ] for the Perl language and ]s; {{as of|December 2022|lc=y}}, it carries over 211,850 modules in 43,865 distributions, written by more than 14,324 authors, and is mirrored worldwide at more than 245 locations.<ref>{{Cite web |url=https://www.cpan.org/ |title=CPAN |access-date=2022-12-19 |publisher=] |archive-date=October 3, 2019 |archive-url=https://web.archive.org/web/20191003040107/https://www.cpan.org/ |url-status=live}}</ref> | |||
==Language structure== | |||
===Example Program=== | |||
In Perl, the canonical "]" program is: | |||
Perl 5.004 was released on May 15, 1997, and included, among other things, the UNIVERSAL package, giving Perl a base object from which all ] were automatically derived and the ability to require versions of modules. Another significant development was the inclusion of the ] module,<ref name="5004delta">{{Cite web |url=http://perldoc.perl.org/perl5004delta.html |title=perl5004delta – what's new for perl5.004 |access-date=2011-01-08 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=February 27, 2011 |archive-url=https://web.archive.org/web/20110227200616/http://perldoc.perl.org/perl5004delta.html |url-status=live}}</ref> which contributed to Perl's popularity as a ].<ref name="patwardhan02">{{Cite book |last1=Patwardhan |first1=Nathan |last2=Siever |first2=Ellen |last3=Spainhour |first3=Stephen |title=Perl in a Nutshell, Second Edition |publisher=] |year=2002 |isbn=978-0-596-00241-1 |url=https://archive.org/details/perlinnutshell00patw}}</ref> | |||
<nowiki>#</nowiki>!/usr/bin/perl | |||
print "Hello, world!\n"; | |||
Perl 5.004 added support for ], ], ], and ].<ref name="5004delta"/> | |||
The first line is the ], which tells the operating system where to find the Perl interpreter. The second line prints the string ''Hello, world!'' and a ] (like a person pressing 'Return' or 'Enter'). | |||
Perl 5.005 was released on July 22, 1998. This release included several enhancements to the ] engine, new hooks into the backend through the <code>B::*</code> modules, the <code>qr//</code> regex quote operator, a large selection of other new core modules, and added support for several more operating systems, including ].<ref name="5005delta">{{Cite web |url=http://perldoc.perl.org/perl5005delta.html |title=perl5005delta - what's new for perl5.005 |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=February 3, 2011 |archive-url=https://web.archive.org/web/20110203100249/http://perldoc.perl.org/perl5005delta.html |url-status=live}}</ref> | |||
The shebang is the usual way to invoke the interpreter on Unix systems. | |||
Windows systems may rely on the shebang, | |||
or they may associate a <tt>.pl</tt> ] with the Perl interpreter. | |||
===2000–2020=== | |||
Here is a one-line, throw-away Perl program that does ] encoding/decoding. | |||
{| class="wikitable floatright" | |||
It is entered and run directly on the command line: | |||
|- | |||
! Major version<ref name="perlhist"/> | |||
! Latest update<ref>{{cite web |url=https://www.cpan.org/src/README.html |title=Perl Source |publisher=cpan.org |access-date=2023-11-26}}</ref> | |||
|- | |||
| {{Version|o|5.4}} | |||
| 1999-04-29 | |||
|- | |||
| {{Version|o|5.5}} | |||
| 2004-02-23 | |||
|- | |||
| {{Version|o|5.6}} | |||
| 2003-11-15 | |||
|- | |||
| {{Version|o|5.8}} | |||
| 2008-12-14 | |||
|- | |||
| {{Version|o|5.10}} | |||
| 2009-08-22 | |||
|- | |||
| {{Version|o|5.12}} | |||
| 2012-11-10 | |||
|- | |||
| {{Version|o|5.14}} | |||
| 2013-03-10 | |||
|- | |||
| {{Version|o|5.16}} | |||
| 2013-03-11 | |||
|- | |||
| {{Version|o|5.18}} | |||
| 2014-10-01 | |||
|- | |||
| {{Version|o|5.20}} | |||
| 2015-09-12 | |||
|- | |||
| {{Version|o|5.22}} | |||
| 2017-07-15 | |||
|- | |||
| {{Version|o|5.24}} | |||
| 2018-04-14 | |||
|- | |||
| {{Version|o|5.26}} | |||
| 2018-11-29 | |||
|- | |||
| {{Version|o|5.28}} | |||
| 2020-06-01 | |||
|- | |||
| {{Version|o|5.30}} | |||
| 2020-06-01 | |||
|- | |||
| {{Version|o|5.32}} | |||
| 2021-01-23 | |||
|- | |||
| {{Version|o|5.34}} | |||
| 2023-11-29 | |||
|- | |||
| {{Version|o|5.36}} | |||
| 2023-11-29 | |||
|- | |||
| {{Version|co|5.38}} | |||
| 2023-11-29 | |||
|- | |||
| {{Version|c|5.40}} | |||
| 2024-06-09 | |||
|- | |||
| colspan="99" |<small>{{Version|lv|show=011111|}}</small> | |||
|} | |||
<!-- | |||
| {{Version|cp|5.39}} | |||
| 2023-04-20 | |||
|- | |||
| {{Version|p|7.0}} | |||
| 2024? | |||
|- | |||
--> | |||
Perl 5.6 was released on March 22, 2000. Major changes included ] support, ] string representation, support for files over 2 GiB, and the "our" keyword.<ref name="56delta">{{cite web |url=http://perldoc.perl.org/perl56delta.html |title=perl56delta - what's new for perl v5.6.0 |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=February 2, 2011 |archive-url=https://web.archive.org/web/20110202135358/http://perldoc.perl.org/perl56delta.html |url-status=live}}</ref><ref name="561delta">{{cite web |url=http://perldoc.perl.org/perl561delta.html |title=perl56delta - what's new for perl v5.6.x |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=November 18, 2010 |archive-url=https://web.archive.org/web/20101118101544/http://perldoc.perl.org/perl561delta.html |url-status=live}}</ref> When developing Perl 5.6, the decision was made to switch the ] scheme to one more similar to other open source projects; after 5.005_63, the next version became 5.5.640, with plans for development versions to have odd numbers and stable versions to have even numbers.<ref>{{Cite web |title=Perl {{!}} Definition, History, & Facts {{!}} Britannica |url=https://www.britannica.com/technology/Perl |access-date=2022-06-15 |website=www.britannica.com |language=en}}</ref> | |||
perl -pe 'tr/A-Za-z/N-ZA-Mn-za-m/' < input_file > output_file | |||
In 2000, Wall put forth a call for suggestions for a new version of Perl from the community. The process resulted in 361 RFC (]) documents that were to be used in guiding development of Perl 6. In 2001,<ref>{{cite web |url=http://dev.perl.org/perl6/doc/design/apo/A01.html |title=Apocalypse 1: The Ugly, the Bad, and the Good |access-date=2011-01-08 |last=Wall |first=Larry |archive-date=November 23, 2010 |archive-url=https://web.archive.org/web/20101123182201/http://dev.perl.org/perl6/doc/design/apo/A01.html |url-status=dead}}</ref> work began on the "Apocalypses" for Perl 6, a series of documents meant to summarize the change requests and present the design of the next generation of Perl. They were presented as a digest of the RFCs, rather than a formal document. At this time, Perl 6 existed only as a description of a language.{{Citation needed|date=December 2020}} | |||
===Data types=== | |||
Perl has three fundamental ]s: ]s, ], and ]: | |||
*A scalar is a single value; it may be a number, a ] or a ] | |||
*A list is an ordered collection of scalars (a variable that holds a list is called an ''array'') | |||
*A hash, or ], is a map from strings to scalars; the strings are called ''keys'' and the scalars are called ''values''. | |||
Perl 5.8 was first released on July 18, 2002, and further 5.X versions have been released approximately yearly since then. Perl 5.8 improved Unicode support, added a new I/O implementation, added a new thread implementation, improved numeric accuracy, and added several new modules.<ref name="perl58delta">{{cite web |url=http://perldoc.perl.org/perl58delta.html |title=perl58delta - what is new for perl v5.8.0 |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=November 21, 2010 |archive-url=https://web.archive.org/web/20101121023149/http://perldoc.perl.org/perl58delta.html |url-status=live}}</ref> As of 2013, this version was still the most popular Perl version and was used by ] ] 5, ] 10, ] 10, ] 11.31, and ] 5. | |||
All variables are marked by a leading ], | |||
which identifies the data type. The same name may be used for variables of different types, without conflict. | |||
In 2004, work began on the "Synopses" – documents that originally summarized the Apocalypses, but which became the specification for the Perl 6 language. In February 2005, ] began work on ], a Perl 6 interpreter written in ].<ref>{{cite web |url=http://www.perl.com/pub/a/2005/03/03/pugs_interview.html |title=A Plan for Pugs |date=2005-03-03 |publisher=] |access-date=2011-01-27 |archive-date=September 8, 2012 |archive-url=https://archive.today/20120908200150/http://www.perl.com/pub/2005/03/03/pugs_interview.html |url-status=live}}</ref> This was the first concerted effort toward making Perl 6 a reality. This effort stalled in 2006.<ref>{{cite web |url=http://www.perlmonks.org/?node_id=835936 |title=Re: How to Implement Perl 6 in Ten Years |access-date=2011-01-03 |last=Tang |first=Audrey |date=2010-04-21 |publisher=] |archive-date=May 11, 2011 |archive-url=https://web.archive.org/web/20110511190417/http://www.perlmonks.org/?node_id=835936 |url-status=live}}</ref> | |||
$foo # a scalar | |||
@foo # a list | |||
%foo # a hash | |||
The Perl On New Internal Engine (PONIE) project existed from 2003 until 2006. It was to be a bridge between Perl 5 and 6, and an effort to rewrite the Perl 5 interpreter to run on the Perl 6 ]. The goal was to ensure the future of the millions of lines of Perl 5 code at thousands of companies around the world.<ref>{{citation|last1=Broadwell|first1=Geoff|date=August 8, 2005<!-- 8:52PM -->|title=OSCON 4.4: Inside Ponie, the Bridge from Perl 5 to Perl 6|url=http://www.oreillynet.com/onlamp/blog/2005/08/oscon_44_inside_ponie_the_brid.html|archive-url=https://web.archive.org/web/20120314013450/http://www.oreillynet.com/onlamp/blog/2005/08/oscon_44_inside_ponie_the_brid.html|publisher=O'Reilly ONLamp Blog|access-date=June 27, 2016|archive-date=March 14, 2012|url-status=live}}</ref> The PONIE project ended in 2006 and is no longer being actively developed. Some of the improvements made to the Perl 5 interpreter as part of PONIE were folded into that project.<ref>{{citation|last1=Vincent|first1=Jesse|author1-link=Jesse Vincent|title=Ponie has been put out to pasture|date=August 23, 2006<!-- 10:40 PM -->|url=http://news.perlfoundation.org/2006/08/ponie_has_been_put_out_to_past.html|df=mdy-all|archive-url=https://web.archive.org/web/20090627091007/http://news.perlfoundation.org/2006/08/ponie_has_been_put_out_to_past.html|publisher=The Perl Foundation|access-date=January 15, 2019|archive-date=June 27, 2009|url-status=dead}}</ref> | |||
Numbers are written in the usual way; strings are enclosed by quotes of various kinds. | |||
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. These included a ] (called "given"/"when"), regular expressions updates, and the ''smart match operator'' (~~).<ref name="5100delta">{{cite web |url=http://perldoc.perl.org/perl5100delta.html |title=perl5100delta - what is new for perl 5.10.0 |access-date=2011-01-08 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=December 21, 2010 |archive-url=https://web.archive.org/web/20101221024004/http://perldoc.perl.org/perl5100delta.html |url-status=live}}</ref><ref name="perlsyn-smart">{{cite web |url=http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail |title=perlsyn - Perl syntax |access-date=2011-01-21 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=August 26, 2013 |archive-url=https://web.archive.org/web/20130826100652/http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail |url-status=live}}</ref> | |||
$n = 42; | |||
Around this same time, development began in earnest on another implementation of Perl 6 known as ] Perl, developed in tandem with the ]. As of November 2009, Rakudo Perl has had regular monthly releases and now is the most complete implementation of Perl 6. | |||
$name = "joe"; | |||
$color = 'red'; | |||
A major change in the development process of Perl 5 occurred with Perl 5.11; the development community has switched to a monthly release cycle of development releases, with a yearly schedule of stable releases. By that plan, bugfix point releases will follow the stable releases every three months.{{Citation needed|date=December 2020}} | |||
A list is written by listing its elements, | |||
separated by commas, and enclosed by parentheses where required by operator precedence. | |||
On April 12, 2010, Perl 5.12.0 was released. Notable core enhancements include new <code>package NAME VERSION</code> syntax, the ] (intended to mark placeholder code that is not yet implemented), implicit {{Not a typo|strictures}}, full ] compliance, regex conversion overloading, ] support, and ] 5.2.<ref name="5120delta">{{cite web |url=http://perldoc.perl.org/perl5120delta.html |title=perl5120delta - what is new for perl v5.12.0 |access-date=2011-01-08 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=January 4, 2011 |archive-url=https://web.archive.org/web/20110104093548/http://perldoc.perl.org/perl5120delta.html |url-status=live}}</ref> | |||
@scores = (32, 45, 16, 5); | |||
On May 14, 2011, Perl 5.14 was released with ] support built-in.<ref>{{cite web|url=https://metacpan.org/pod/distribution/perl/pod/perl5140delta.pod|title=perl5140delta - what is new for perl v5.14.0 - metacpan.org|website=metacpan.org|access-date=July 22, 2017|archive-date=July 25, 2018|archive-url=https://web.archive.org/web/20180725004523/https://metacpan.org/pod/distribution/perl/pod/perl5140delta.pod|url-status=live}}</ref> | |||
A hash may be initialized from a list of key/value pairs. | |||
On May 20, 2012, Perl 5.16 was released. Notable new features include the ability to specify a given version of Perl that one wishes to emulate, allowing users to upgrade their version of Perl, but still run old scripts that would normally be incompatible.<ref name="5160delta_version">{{cite web |url=https://perldoc.perl.org/perl5160delta |title=perl5160delta - what is new for perl v5.16.0 |access-date=2012-05-21 |website=perldoc.perl.org}}</ref>{{Failed verification|date=June 2022}} Perl 5.16 also updates the core to support ] 6.1.<ref name="5160delta_version"/> | |||
%favorite = (joe => 'red', | |||
sam => 'blue'); | |||
On May 18, 2013, Perl 5.18 was released. Notable new features include the new dtrace hooks, lexical subs, more CORE:: subs, overhaul of the hash for security reasons, support for Unicode 6.2.<ref name="5180delta_version">{{cite web |url=https://metacpan.org/pod/release/RJBS/perl-5.18.1/pod/perl5180delta.pod |title=perl5180delta - what is new for perl v5.18.0 - Perl programming language |access-date=2013-10-27 |work=Perl 5 version 18.0 documentation |publisher=metacpan.org |archive-date=October 29, 2013 |archive-url=https://web.archive.org/web/20131029224638/https://metacpan.org/pod/release/RJBS/perl-5.18.1/pod/perl5180delta.pod |url-status=live}}</ref> | |||
Individual elements of a list are accessed by providing a numerical | |||
index, in square brackets. Individual values in a hash are | |||
accessed by providing the corresponding key, in curly braces. The | |||
<tt>$</tt> sigil identifies the accessed element as a scalar. | |||
On May 27, 2014, Perl 5.20 was released. Notable new features include subroutine signatures, hash slices/new slice syntax, postfix dereferencing (experimental), Unicode 6.3, and a {{Not a typo|rand()}} function using a consistent random number generator.<ref name="5200delta_version">{{cite web |url=https://metacpan.org/source/RJBS/perl-5.20.0/pod/perldelta.pod |title=perl5200delta - what is new for perl v5.20.0 - Perl programming language |access-date=2014-05-27 |work=Perl 5 version 20.0 documentation |publisher=metacpan.org |archive-date=May 27, 2014 |archive-url=https://archive.today/20140527190905/https://metacpan.org/source/RJBS/perl-5.20.0/pod/perldelta.pod |url-status=live}}</ref> | |||
$scores # an element of @scores | |||
$favorite{joe} # a value in %favorite | |||
Some observers credit the release of Perl 5.10 with the start of the Modern Perl movement.<ref> {{Webarchive|url=https://web.archive.org/web/20121027105918/http://www.modernperlbooks.com/mt/2009/07/milestones-in-the-perl-renaissance.html |date=October 27, 2012}}. Modernperlbooks.com. Retrieved on 2013-07-17.</ref> In particular, this phrase describes a style of development that embraces the use of the CPAN, takes advantage of recent developments in the language, and is rigorous about creating high quality code.<ref> {{Webarchive|url=https://web.archive.org/web/20120928232457/http://modernperlbooks.com/books/modern_perl/ |date=September 28, 2012}}. Modernperlbooks.com. Retrieved on 2013-07-17.</ref> While the book ''Modern Perl''<ref> {{Webarchive|url=https://web.archive.org/web/20111222045417/http://onyxneon.com/books/modern_perl/ |date=December 22, 2011}}. Onyxneon.com. Retrieved on 2013-07-17.</ref> may be the most visible standard-bearer of this idea, other groups such as the Enlightened Perl Organization<ref>{{cite web|url=http://www.enlightenedperl.org/|title=Enlightened Perl|website=Enlightened Perl|access-date=September 28, 2012|archive-date=February 5, 2014|archive-url=https://web.archive.org/web/20140205015536/http://www.enlightenedperl.org/|url-status=dead}}</ref> have taken up the cause. | |||
Multiple elements may be accessed by using the <tt>@</tt> sigil instead | |||
(identifying the result as a list). | |||
In late 2012 and 2013, several projects for alternative implementations for Perl 5 started: Perl5 in ] by the Rakudo Perl team,<ref>{{cite web |url=http://www.yapcna.org/yn2013/talk/4725 |title=YAPC::NA 2013 – June 3–5, Austin, Texas |publisher=Yapcna.org |date=2013-06-04 |access-date=2014-04-11 |archive-url=https://web.archive.org/web/20130622201417/http://www.yapcna.org/yn2013/talk/4725 |archive-date=June 22, 2013 |url-status=dead}}</ref> ''{{Not a typo|moe}}'' by Stevan Little and friends,<ref>{{cite web |last=Little |first=Stevan |url=http://blogs.perl.org/users/stevan_little/2013/02/what-is-moe-a-clarification.html |title=What is Moe (a clarification) | Stevan Little |publisher=Blogs.perl.org |date=2013-02-08 |access-date=2014-04-11 |archive-date=December 19, 2013 |archive-url=https://web.archive.org/web/20131219185710/http://blogs.perl.org/users/stevan_little/2013/02/what-is-moe-a-clarification.html |url-status=live}}</ref> ''{{Not a typo|p2}}''<ref>{{cite web |url=http://perl11.org/p2/ |title=p2 on potion |publisher=Perl11.org |date=2004-02-07 |access-date=2014-04-11 |archive-date=September 24, 2013 |archive-url=https://web.archive.org/web/20130924023845/http://perl11.org/p2/ |url-status=live}}</ref> by the Perl11 team under Reini Urban, ''{{Not a typo|gperl}}'' by {{Not a typo|goccy}},<ref>{{cite web |url=https://github.com/goccy/gperl/ |title=goccy/gperl 路 GitHub |publisher=GitHub.com |access-date=2014-04-11 |archive-date=February 23, 2015 |archive-url=https://web.archive.org/web/20150223170215/https://github.com/goccy/gperl |url-status=live}}</ref> and ''{{Not a typo|rperl}},'' a Kickstarter project led by Will Braswell and affiliated with the Perl11 project.<ref>{{cite web |url=http://rperl.org/faq.html |title=rperl |publisher=RPerl.org |access-date=2014-08-11 |archive-date=October 18, 2014 |archive-url=https://web.archive.org/web/20141018002115/http://rperl.org/faq.html |url-status=live}}</ref> | |||
@scores # three elements of @scores | |||
@favorite{'joe', 'sam'} # two values in %favorite | |||
=== Perl 6 and Raku === | |||
The number of elements in an array can be obtained by evalulating the | |||
{{Main|Raku (programming language)}} | |||
array in scalar context or with the help of the <tt>$#</tt> ]. | |||
] | |||
The latter gives the index of the last element in the array, not the number of elements. | |||
At the 2000 ], Jon Orwant made a case for a major new language initiative.<ref>{{cite web |url=http://www.nntp.perl.org/group/perl.perl6.meta/2000/10/msg424.html |title=Transcription of Larry's talk |access-date=2011-01-25 |last=Torkington |first=Nathan |publisher=nntp.perl.org |archive-date=May 1, 2011 |archive-url=https://web.archive.org/web/20110501081806/http://www.nntp.perl.org/group/perl.perl6.meta/2000/10/msg424.html |url-status=live}}</ref> This led to a decision to begin work on a redesign of the language, to be called Perl 6. Proposals for new language features were solicited from the Perl community at large, which submitted more than 300 ].<ref>{{Cite web|title=Perl6 - The future of Perl|url=https://www.java-samples.com/showtutorial.php?tutorialid=1443|access-date=2021-05-18|website=www.java-samples.com}}</ref> | |||
$count = @friends; | |||
$#friends # the index of the last element in @friends | |||
$#friends+1 # usually the number of elements in @friends | |||
# this is one more than $#friends because the first element is at | |||
# index 0, not 1 | |||
Wall spent the next few years digesting the RFCs and synthesizing them into a coherent framework for Perl 6. He presented his design for Perl 6 in a series of documents called "apocalypses" – numbered to correspond to chapters in ''Programming Perl''. {{as of|2011|January}}, the developing specification of Perl 6 was encapsulated in design documents called Synopses – numbered to correspond to Apocalypses.<ref name="syn6">{{cite web |url=http://perlcabal.org/syn/ |title=Official Perl 6 Documentation |access-date=2011-01-25 |publisher=The Perl 6 Project |archive-url=https://web.archive.org/web/20090831103918/http://perlcabal.org/syn/ |archive-date=August 31, 2009 |url-status=dead}}</ref> | |||
There are a few functions that operate on entire hashes. | |||
Thesis work by ], overseen by Wall, considered the possible use of the ] as a runtime for Perl.<ref>{{cite thesis |last=Kuhn |first=Bradley M. |author-link=Bradley M. Kuhn |title=Considerations on Porting Perl to the Java Virtual Machine |type=MS thesis |publisher=University of Cincinnati |date=January 2001 |url=http://www.ebb.org/bkuhn/writings/technical/thesis/ |access-date=2008-06-28 |archive-date=March 21, 2008 |archive-url=https://web.archive.org/web/20080321164747/http://ebb.org/bkuhn/writings/technical/thesis/ |url-status=live}}</ref> Kuhn's thesis showed this approach to be problematic. In 2001, it was decided that Perl 6 would run on a cross-language ] called ]. | |||
@names = keys %address; | |||
@addresses = values %address; | |||
In 2005, ] created the ] project, an implementation of Perl 6 in ]. This acted as, and continues to act as, a test platform for the Perl 6 language (separate from the development of the actual implementation), allowing the language designers to explore. The Pugs project spawned an active Perl/Haskell cross-language community centered around the ] #raku IRC channel. Many ] influences were absorbed by the Perl 6 design team.<ref>{{Cite book|author1=chromatic|author1-link=chromatic (programmer)|url=https://books.google.com/books?id=JUjmsgEACAAJ|title=Modern Perl|date=2015|publisher=Pragmatic Bookshelf|isbn=978-1-68050-088-2|language=en}}</ref> | |||
===Control structures=== | |||
{{main|Perl control structures}} | |||
In 2012, Perl 6 development was centered primarily on two compilers:<ref>{{cite web |url=http://perl6.org/compilers/features |title=Feature comparison of Perl 6 compilers |access-date=March 28, 2012 |archive-url=https://web.archive.org/web/20170811073233/https://perl6.org/compilers/features |archive-date=August 11, 2017 |url-status=dead}}</ref> | |||
Perl has several kinds of control structures. | |||
# ], an implementation running on the Parrot virtual machine and the Java virtual machine.<ref>{{cite web |last=Worthington |first=Jonathan |title=Rakudo JVM News: More tests, plus Thread and Promise prototypes |url=http://6guts.wordpress.com/2013/07/15/rakudo-jvm-news-more-tests-plus-thread-and-promise-prototypes/ |work=6guts |date=July 15, 2013 |access-date=July 24, 2013 |archive-date=October 5, 2013 |archive-url=https://web.archive.org/web/20131005055559/http://6guts.wordpress.com/2013/07/15/rakudo-jvm-news-more-tests-plus-thread-and-promise-prototypes/ |url-status=live}}</ref> | |||
# ], which targets the ]. | |||
In 2013, ] ("Metamodel On A Runtime"), a C language-based ] designed primarily for Rakudo was announced.<ref>{{cite web |last=Worthington |first=Jonathan |title=MoarVM: A virtual machine for NQP and Rakudo |url=http://6guts.wordpress.com/2013/05/31/moarvm-a-virtual-machine-for-nqp-and-rakudo/ |work=6guts |date=May 31, 2013 |access-date=July 24, 2013 |archive-date=July 9, 2013 |archive-url=https://web.archive.org/web/20130709185252/http://6guts.wordpress.com/2013/05/31/moarvm-a-virtual-machine-for-nqp-and-rakudo/ |url-status=live}}</ref> | |||
It has block-oriented control structures, similar to those in the C and ] programming languages. Conditions are surrounded by parentheses, and controlled blocks are surrounded by braces: | |||
In October 2019, Perl 6 was renamed to Raku.<ref>{{cite web |url=https://lwn.net/Articles/802329/ |title=rename-lwn |access-date=November 10, 2019 |archive-url=https://web.archive.org/web/20191017155422/https://lwn.net/Articles/802329/ |archive-date=October 17, 2019 |url-status=dead}}</ref> | |||
''label'' while ( ''cond'' ) { ... } | |||
''label'' while ( ''cond'' ) { ... } continue { ... } | |||
''label'' for ( ''init-expr'' ; ''cond-expr'' ; ''incr-expr'' ) { ... } | |||
''label'' foreach ''var'' ( ''list'' ) { ... } | |||
''label'' foreach ''var'' ( ''list'' ) { ... } continue { ... } | |||
if ( ''cond'' ) { ... } | |||
if ( ''cond'' ) { ... } else { ... } | |||
if ( ''cond'' ) { ... } elsif ( ''cond'' ) { ... } else { ... } | |||
{{As of|2017}} only the Rakudo implementation and MoarVM are under active development, and other virtual machines, such as the Java Virtual Machine and ], are supported.<ref>{{cite web |url=https://github.com/rakudo/rakudo/ |title=rakudo/rakudo - GitHub |publisher=GitHub.com |access-date=2013-09-21 |archive-date=July 29, 2017 |archive-url=https://web.archive.org/web/20170729084734/https://github.com/rakudo/rakudo/ |url-status=live}}</ref> | |||
Where only a single statement is being controlled, statement modifiers provide a lighter syntax: | |||
=== Perl 7 === | |||
''statement'' if ''cond'' ; | |||
''statement'' unless ''cond'' ; | |||
''statement'' while ''cond'' ; | |||
''statement'' until ''cond'' ; | |||
''statement'' foreach ''list'' ; | |||
In June 2020, Perl 7 was announced as the successor to Perl 5.<ref name="perl7announced">{{cite web |url=https://news.perlfoundation.org/post/perl_7_announced_sawyerx_conference |title=Perl 7 announced at Perl Conference in the Cloud |publisher=perlfoundation.org |date=2020-06-24 |access-date=2020-06-24 |archive-date=June 26, 2020 |archive-url=https://web.archive.org/web/20200626213418/https://news.perlfoundation.org/post/perl_7_announced_sawyerx_conference |url-status=live}}</ref> Perl 7 was to initially be based on Perl 5.32 with a release expected in first half of 2021, and release candidates sooner.<ref name="perl7">{{cite web |url=https://www.perl.com/article/announcing-perl-7/ |title=Announcing Perl 7 |publisher=perl.com |date=2020-06-24 |access-date=2020-06-24 |archive-date=June 24, 2020 |archive-url=https://web.archive.org/web/20200624160531/https://www.perl.com/article/announcing-perl-7/ |url-status=live}}</ref> | |||
Short-circuit logical operators are commonly used to effect control flow at the expression level: | |||
This plan was revised in May 2021, without any release timeframe or version of Perl 5 for use as a baseline specified.<ref>{{Cite web|title=Steering Council meeting #019 2021-05-06|url=https://www.nntp.perl.org/group/perl.perl5.porters/2021/05/msg260050.html|last1=Clark|first1=Nicholas|date=2021-05-09|quote=The plan remains that there will be a Perl 7 bump, but not immediately after 5.34.0 is released.{{nbsp}}... We don't think that we can deliver on in 12 months.|access-date=2021-05-17|website=www.nntp.perl.org|archive-date=2021-05-18|archive-url=https://web.archive.org/web/20210518015233/https://www.nntp.perl.org/group/perl.perl5.porters/2021/05/msg260050.html|url-status=live}}</ref> When Perl 7 would be released, Perl 5 would have gone into long term maintenance. Supported Perl 5 versions however would continue to get important security and bug fixes.<ref>{{cite book |url=https://leanpub.com/preparing_for_perl7 |title=Preparing for Perl 7d |publisher=leanpub.com |date=2020-06-24 |access-date=2020-06-24 |archive-date=June 25, 2020 |archive-url=https://web.archive.org/web/20200625004047/https://leanpub.com/preparing_for_perl7 |url-status=live}}</ref> | |||
''expr'' and ''expr'' | |||
''expr'' or ''expr'' | |||
Perl 7 was announced on 24 June 2020 at "The Perl Conference in the Cloud" as the successor to Perl 5.<ref name="perl7"/><ref name="perl7announced"/> Based on Perl 5.32, Perl 7 was planned to be ] with modern Perl 5 code; Perl 5 code, without ] (pragma) header needs adding <code>use compat::perl5;</code> to stay compatible, but modern code can drop some of the boilerplate. | |||
The flow control keywords <tt>next</tt>, <tt>last</tt>, <tt>return</tt>, and <tt>redo</tt> are expressions, so they can be used with short-circuit operators. | |||
The plan to go to Perl 7 brought up more discussion, however, and the Perl Steering Committee canceled it to avoid issues with backward compatibility for scripts that were not written to the pragmas and modules that would become the default in Perl 7. Perl 7 will only come out when the developers add enough features to warrant a major release upgrade.<ref>{{cite web |last1=Perl Steering Council |title=What happened to Perl 7? |url=https://blogs.perl.org/users/psc/2022/05/what-happened-to-perl-7.html |website=blogs.perl.org |access-date=7 July 2022}}</ref> | |||
Perl also has two implicit looping constructs: | |||
== Design == | |||
''results'' = grep { ... } ''list'' | |||
{{Main|Perl language structure}} | |||
''results'' = map { ... } ''list'' | |||
=== Philosophy === | |||
<tt>grep</tt> returns all elements of ''list'' for which the controlled block evaluates to true. <tt>map</tt> evaluates the controlled block for each element of ''list'' and returns a list of the resulting values. These constructs enable a simple functional programming style. | |||
According to Wall, Perl has two slogans. The first is "There's more than one way to do it," commonly known as TMTOWTDI, (pronounced ''Tim Toady''). As proponents of this motto argue, this philosophy makes it easy to write concise statements.<ref>{{cite web |last1=Richardson |first1=Marjorie |title=Larry Wall, the Guru of Perl {{!}} Linux Journal |url=https://www.linuxjournal.com/article/3394 |website=www.linuxjournal.com |publisher=Linux Journal |access-date=16 January 2023}}</ref><ref>{{Cite journal |last=Schwartz |first=Alan |date=December 1998 |title=Tutorial: Perl, a psychologically efficient reformatting language |journal=Behavior Research Methods, Instruments, & Computers |language=en |volume=30 |issue=4 |pages=605–609 |doi=10.3758/BF03209477 |s2cid=61028367 |issn=0743-3808|doi-access=free}}</ref><ref>{{Cite journal |last=Gilbert |first=James G. R. |date=March 2002 |title=How to become a programming tadpole |url=http://www.nature.com/articles/nbt0302-221 |journal=Nature Biotechnology |language=en |volume=20 |issue=3 |pages=221 |doi=10.1038/nbt0302-221 |s2cid=38728402 |issn=1087-0156}}</ref> | |||
There is no ] (multi-way branch) in Perl 5. The Perl documentation describes a half-dozen ways to achieve the same effect by using other control structures, none entirely satisfactory. A very general and flexible switch statement has been designed for ]. The <tt>Switch</tt> module makes most of the functionality of the Perl 6 switch available to Perl 5 programs, although it is often criticised for being a source filter, and thus failure-prone. The next stable version of Perl 5, Perl 5.10, will have the ] given/when switch-statement. | |||
The second slogan is "Easy things should be easy and hard things should be possible".<ref name="programmingperl2"/> | |||
Perl includes a <tt>goto ''label''</tt> statement, but it is rarely used. Some consider its use poor coding practice. The implementation is slow, and situations where a <tt>goto</tt> is called for in other languages don't occur as often in Perl and are often better handled with other control structures, such as labeled loops. | |||
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 ] technology. Many earlier computer languages, such as ] and C, aimed to make efficient use of expensive computer hardware. In contrast, Perl was designed so that computer programmers could write programs more quickly and easily.<ref>{{Cite web |date=February 13, 2014 |title=The Fall Of Perl, The Web's Most Promising Language |url=https://www.fastcompany.com/3026446/the-fall-of-perl-the-webs-most-promising-language |website=FastCompany}}</ref> | |||
There is also a <tt>goto &''sub''</tt> statement that performs a ]. | |||
It terminates the current subroutine and immediately calls the specified <tt>''sub''</tt>. | |||
Use of this form is culturally accepted but unusual because it is rarely needed. | |||
Perl has many features that ease the task of the programmer at the expense of greater ] and memory requirements. These include automatic memory management; ]; strings, lists, and hashes; regular expressions; ]; and an <code>eval()</code> function. Perl follows the theory of "no built-in limits",<ref name="schwartz01"/> an idea similar to the ] rule. | |||
===Subroutines=== | |||
]s are defined with the <tt>sub</tt> keyword, | |||
and invoked simply by naming them. | |||
Subroutine definitions may appear anywhere in the program. | |||
Parentheses are required for calls that precede the definition. | |||
Wall was trained as a linguist, and the design of Perl is very much informed by ] principles. Examples include ] (common constructions should be short), good end-weighting (the important information should come first), and a large collection of ]s. Perl favors language constructs that are concise and natural for humans to write, even where they complicate the Perl interpreter.<ref>{{Cite web|last=Wall|first=Larry|title=perl - The Perl 5 language interpreter - Perldoc Browser|url=https://perldoc.perl.org/perl|access-date=2021-06-24|website=perldoc.perl.org}}</ref> | |||
foo(); | |||
sub foo { ... } | |||
foo; | |||
Perl's ] reflects the idea that "things that are different should look different."<ref name="wall97">{{cite journal |url=http://www.linuxjournal.com/article/2070 |title=Wherefore Art, Thou? |access-date=2011-03-13 |last=Wall |first=Larry |date=1997-03-01 |journal=] |archive-date=December 9, 2010 |archive-url=https://web.archive.org/web/20101209021107/http://www.linuxjournal.com/article/2070 |url-status=live}}</ref> 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. | |||
A list of arguments may be provided after the subroutine name. | |||
Arguments may be scalars, lists, or hashes. | |||
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."<ref name="programmingperl2"/> One consequence of this is that Perl is not a tidy language. It includes many features, tolerates exceptions to its rules, and employs ] to resolve syntactical ambiguities. Because of the forgiving nature of the compiler, bugs can sometimes be hard to find. Perl's function documentation remarks on the variant behavior of built-in functions in list and scalar contexts by saying, "In general, they do what you want, unless you want consistency."<ref name="perlfunc">{{cite web |url=http://perldoc.perl.org/perlfunc.html |title=perlfunc - Perl builtin functions |access-date=2011-01-10 |work=Perl 5 version 12.2 documentation |publisher=perldoc.perl.org |archive-date=January 6, 2011 |archive-url=https://web.archive.org/web/20110106003034/http://perldoc.perl.org/perlfunc.html |url-status=live}}</ref> | |||
foo $x, @y, %z; | |||
=== Features === | |||
The parameters to a subroutine need not be declared as to either number or type; in fact, they may vary from call to call. | |||
Arrays are expanded to their elements, hashes are expanded to a list of key/value pairs, and the whole lot is passed into the subroutine as one undifferentiated list of scalars. | |||
The overall structure of Perl derives broadly from C. Perl is ] in nature, with ]s, ], ]s, ]-delimited ]s, ]s, and ]s.<ref>{{Cite book|last=Nagpal|first=D.P.|title=Web Design Technology|publisher=S. Chand|year=2010|isbn=978-8121927635|location=India|pages=700|language=English}}</ref> | |||
Whatever arguments are passed are available to the subroutine in the special array <tt>@_</tt>. | |||
The elements of <tt>@_</tt> are aliased to the actual arguments; | |||
changing an element of <tt>@_</tt> changes the corresponding argument. | |||
Perl also takes features from shell programming. All variables are marked with leading ], which allow variables to be ] directly into ]. 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 <code>@arrayname</code>), an individual member of the array is denoted by the scalar sigil "$" (for example <code>$arrayname</code>). 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 ], and calling ] facilities.{{Citation needed|date=December 2020}} | |||
Elements of <tt>@_</tt> may be accessed by subscripting it in the usual way. | |||
Perl takes ] ("associative arrays") from ] and ]s from ]. These simplify many parsing, text-handling, and data-management tasks. Shared with ] is the implicit ] of the last value in a block, and all statements are also expressions which can be used in larger expressions themselves.{{Citation needed|date=December 2020}} | |||
$_, $_ | |||
Perl 5 added features that support complex ]s, ]s (that is, ] as values), and an object-oriented programming model. These include ], packages, class-based ], and ], along with ]s (for example, the <code>strict</code> ]). 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."<ref>{{cite newsgroup |title=title unknown |date=1997-05-10 |message-id=199705101952.MAA00756@wall.org}}{{Dead link|date=November 2014}}</ref> | |||
However, the resulting code can be difficult to read, | |||
and the parameters have ] semantics, | |||
which may be undesirable. | |||
All versions of Perl do automatic ] and automatic ]. The interpreter knows the type and ] requirements of every data object in the program; it allocates and frees storage for them as necessary using ] (so it cannot deallocate ] without manual intervention). Legal ]s – for example, conversions from number to string – are done automatically at ]; illegal type conversions are fatal errors.{{Citation needed|date=December 2020}} | |||
One common idiom is to assign <tt>@_</tt> to a list of named variables. | |||
=== Syntax === | |||
my($x, $y, $z) = @_; | |||
Perl has been referred to as "]" and a "write-only language" by its critics. ] in the first edition of the book '']'',<ref>{{cite journal |title=Developer Update|volume=2 |journal=Dr. Dobb's Developer Update |publisher=Miller-Freeman |year=1995}}</ref><!-- page 15 --> in the first chapter states: "Yes, sometimes Perl looks like line noise to the uninitiated, but to the seasoned Perl programmer, it looks like ]med line noise with a mission in life."<ref name="LP">{{cite book |title=Learning Perl |last=Schwartz |first=Randal L. |author-link=Randal L. Schwartz |publisher=O'Reilly & Associates |year=1993 |title-link=Learning Perl |bibcode=1993lepe.book.....S}}</ref> He also stated that the accusation that Perl is a write-only language could be avoided by coding with "proper care".<ref name="LP"/> The Perl overview document ''{{Not a typo|perlintro}}'' states that the names of built-in "magic" scalar ] "look like punctuation or line noise".<ref>{{cite web |url=http://perldoc.perl.org/perlintro.html |title=perlintro |work=Perl 5 version 18.0 documentation |publisher=Perl 5 Porters and perldoc.perl.org |access-date=2013-06-30 |archive-url=https://web.archive.org/web/20110109121845/http://perldoc.perl.org/perlintro.html |archive-date=January 9, 2011 |url-status=dead}}</ref> However, the English module provides both long and short English alternatives. ''{{Not a typo|perlstyle}}'' document states that line noise in regular expressions could be mitigated using the <code>/x</code> modifier to add whitespace.<ref>{{cite web |url=http://perldoc.perl.org/perlstyle.html |title=perlstyle |work=Perl 5 version 18.0 documentation |publisher=Perl 5 Porters and perldoc.perl.org |access-date=2013-06-30 |archive-url=https://web.archive.org/web/20130626010707/http://perldoc.perl.org/perlstyle.html |archive-date=June 26, 2013 |url-status=dead}}</ref> | |||
This effects both mnemonic parameter names and ] semantics. | |||
The <tt>my</tt> keyword indicates that the following variables are lexically scoped to the containing block. | |||
According to the ''Perl 6 FAQ'', Perl 6 was designed to mitigate "the usual suspects" that elicit the "line noise" claim from Perl 5 critics, including the removal of "the majority of the punctuation variables" and the sanitization of the regex syntax.<ref name="P6FAQ">{{cite web |url=http://www.perl6.org/archive/faq.html |title=Perl 6 FAQ |publisher=Perl 6 Project |access-date=2013-06-30 |archive-date=July 1, 2013 |archive-url=https://web.archive.org/web/20130701183900/http://www.perl6.org/archive/faq.html |url-status=dead}}</ref> The ''Perl 6 FAQ'' also states that what is sometimes referred to as Perl's line noise is "the actual syntax of the language" just as ]s and ] are a part of the ].<ref name="P6FAQ"/> In a December 2012 blog posting, despite claiming that "Rakudo Perl 6 has failed and will continue to fail unless it gets some adult supervision", ] stated that the design of Perl 6 has a "well-defined grammar", an "improved type system, a unified object system with an intelligent metamodel, metaoperators, and a clearer system of context that provides for such niceties as pervasive laziness".<ref name="chromatic-blog">{{cite web |url=http://www.modernperlbooks.com/mt/2012/12/the-implementation-of-perl-5-versus-perl-6.html |title=The Implementation of Perl 5 versus Perl 6 |author1=chromatic |author1-link=chromatic (programmer) |date=2012-12-31 |access-date=2013-06-30 |archive-date=July 29, 2013 |archive-url=https://web.archive.org/web/20130729214209/http://www.modernperlbooks.com/mt/2012/12/the-implementation-of-perl-5-versus-perl-6.html |url-status=live}}</ref> He also stated that "Perl 6 has a coherence and a consistency that Perl 5 lacks."<ref name="chromatic-blog"/> | |||
Another idiom is to shift parameters off of <tt>@_</tt>. This is especially common when the subroutine takes only one argument. | |||
In Perl, one could write the ] as: | |||
my $x = shift; | |||
<syntaxhighlight lang="perl"> | |||
Subroutines may return values. | |||
print "Hello, World!\n"; | |||
</syntaxhighlight> | |||
Here is a more complex Perl program, that counts down seconds from a given starting value: | |||
return 42, $x, @y, %z; | |||
<syntaxhighlight lang="perl"> | |||
If the subroutine does not exit via a <tt>return</tt> statement, | |||
#!/usr/bin/perl | |||
then it returns the last expression evaluated within the subroutine body. Arrays and hashes in the return value are expanded to lists of scalars, just as they are for arguments. | |||
use strict; | |||
use warnings; | |||
my ( $remaining, $total ); | |||
The returned expression is evaluated in the calling context of the subroutine; this can surprise the unwary. | |||
$remaining=$total=shift(@ARGV); | |||
sub list { (4, 5, 6) } | |||
sub array { @x = (4, 5, 6); @x } | |||
$x = list; # returns 6 - last element of list | |||
$x = array; # returns 3 - number of elements in list | |||
@x = list; # returns (4, 5, 6) | |||
@x = array; # returns (4, 5, 6) | |||
STDOUT->autoflush(1); | |||
A subroutine can discover its calling context with the <tt>wantarray</tt> function. | |||
while ( $remaining ) { | |||
sub either { wantarray ? (1, 2) : "Oranges" } | |||
printf ( "Remaining %s/%s \r", $remaining--, $total ); | |||
sleep 1; | |||
$x = either; # returns "Oranges" | |||
} | |||
@x = either; # returns (1, 2) | |||
print "\n"; | |||
===Regular expressions=== | |||
</syntaxhighlight> | |||
{{seealso|Perl regular expression examples}} | |||
The Perl interpreter can also be used for one-off scripts on the command line. The following example (as invoked from an sh-compatible shell, such as ]) translates the string "Bob" in all files ending with .txt in the current directory to "Robert": | |||
The Perl language includes a specialized syntax for writing ]s (REs), and the interpreter contains an engine for matching strings to regular expressions. The regular expression engine uses a ] algorithm, extending its capabilities from simple pattern matching to string capture and substitution. | |||
<syntaxhighlight lang="console"> | |||
The Perl regular expression syntax was originally taken from Unix Version 8 regular expressions. However, it diverged before the first release of Perl, and has since grown to include many more features. Some other languages and applications are now adopting in favor of ] regular expressions. | |||
$ perl -i.bak -lp -e 's/Bob/Robert/g' *.txt | |||
</syntaxhighlight> | |||
=== Implementation === | |||
The <tt>m//</tt> (match) operator introduces a regular expression match. (The leading <tt>m</tt> may be omitted for brevity.) In the simplest case, an expression like | |||
No written ] or standard for the Perl language exists for Perl versions through Perl 5, 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. Perl 6, however, started with a specification,<ref>{{cite web |url=http://www.perl6.org/specification |title=Perl 6 Specification |access-date=2011-01-27 |publisher=The Perl 6 Project |archive-date=December 2, 2009 |archive-url=https://web.archive.org/web/20091202073507/http://www.perl6.org/specification/ |url-status=live}}</ref> and several projects<ref>{{cite web |url=http://www.perl6.org/compilers/ |title=Perl 6 Compilers |access-date=2011-01-27 |publisher=The Perl 6 Project |archive-date=December 2, 2009 |archive-url=https://web.archive.org/web/20091202073302/http://www.perl6.org/compilers/ |url-status=live}}</ref> aim to implement some or all of the specification.{{Citation needed|date=December 2020}} | |||
$x =~ m/abc/ | |||
Perl is implemented as a core interpreter, written in C, together with a large collection of modules, written in Perl and C. {{As of|2010}}, 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 ] tables).{{Citation needed|date=December 2020}} | |||
evaluates to true ] the string <tt>$x</tt> matches the regular expression <tt>abc</tt>. | |||
The interpreter has an object-oriented architecture. All of the elements of the Perl language—scalars, arrays, hashes, coderefs, ]s—are represented in the interpreter by ]. Operations on these structs are defined by a large collection of ], ]s, and functions; these constitute the Perl C ]. The Perl API can be bewildering to the uninitiated, but its entry points follow a consistent ], which provides guidance to those who use it.{{Citation needed|date=December 2020}} | |||
Portions of a regular expression may be enclosed in parentheses; | |||
corresponding portions of a matching string are ''captured''. | |||
Captured strings are assigned to the sequential built-in variables <tt>$1, $2, $3, ...</tt>, | |||
and a list of captured strings is returned as the value of the match. | |||
The life of a Perl interpreter divides broadly into a compile phase and a run phase.<ref>A description of the Perl 5 interpreter can be found in ''Programming Perl'', 3rd Ed., chapter 18. See particularly page 467, which carefully distinguishes run phase and compile phase from ] and ]. Perl "time" and "phase" are often confused.</ref> In Perl, the ''phases'' are the major stages in the interpreter's life-cycle. Each interpreter goes through each phase only once, and the phases follow in a fixed sequence.{{Citation needed|date=December 2020}} | |||
$x =~ m/a(.)c/; # capture the character between 'a' and 'c' | |||
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 <code>]</code> 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 <code>BEGIN</code> blocks executes at run time but in the compile phase.<!-- NOTE TO EDITORS: There is something missing in the preceding sentence -- for one thing, a comma before the conjunction. The sentence might reasonably read 'Code in BEGIN blocks executes NOT at run time, but in the compile phase,' but is that what the author intended? --> | |||
The <tt>s///</tt> (substitute) operator specifies a search and replace operation: | |||
At compile time, the interpreter parses Perl code into a ]. At run time, it executes the program by ]. 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 ] and context propagation, but ] is also performed.<ref>{{Cite web|title=perlguts - Introduction to the Perl API - Perldoc Browser|url=https://perldoc.perl.org/perlguts#Compile-pass-3:-peephole-optimization|access-date=2022-01-24|website=perldoc.perl.org}}</ref> | |||
$x =~ s/abc/aBc/; # upcase the b | |||
Perl has a ] ] because parsing can be affected by run-time code executed during the compile phase.<ref>{{cite web |last=Schwartz |first=Randal |author-link=Randal L. Schwartz |title=On Parsing Perl |url=http://www.perlmonks.org/index.pl?node_id=44722 |access-date=2007-01-03 |archive-date=September 27, 2007 |archive-url=https://web.archive.org/web/20070927000827/http://www.perlmonks.org/index.pl?node_id=44722 |url-status=live}}</ref> Therefore, Perl cannot be parsed by a straight ]/] ]/] combination. Instead, the interpreter implements its own lexer, which coordinates with a modified ] parser to resolve ambiguities in the language.{{Citation needed|date=December 2020}} | |||
Perl regular expressions can take ''modifiers''. These are single-letter suffixes that modify the meaning of the expression: | |||
It is often said that "Only perl can parse Perl",<ref>{{cite web |url=ftp://ftp.ora.com/pub/labs/tpj/tpj2.pdf |title=The Perl Journal #19/9.26 |access-date=2011-02-04 |publisher=] }}{{Dead link|date=August 2024 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> meaning that only the Perl interpreter (''<code>perl</code>'') 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 ] in order to complete parsing in every case. It is a longstanding 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.<ref>{{cite web | |||
$x =~ m/abc/i; # case-insensitive pattern match | |||
|url=http://blogs.perl.org/users/jeffrey_kegler/2011/10/perl-and-parsing-11-are-all-perl-programs-parseable.html | |||
$x =~ s/abc/aBc/g; # global search and replace | |||
|title=Perl and Parsing 11: Are all Perl programs parseable? |last=Kegler |first=Jeffrey |date=October 7, 2011 |access-date=October 25, 2022 | |||
|quote=... we seem to be giving up absolutely nothing. Nobody has ever been able to show a practical downside}}</ref> | |||
Other programs that undertake to parse Perl, such as ] and ], have to contend not only with ambiguous ] but also with the ] of Perl parsing in the general case. ]'s PPI project focused on parsing Perl code as a document (retaining its integrity as a document), instead of parsing Perl as executable code (that not even Perl itself can always do). It was Kennedy who first conjectured that "parsing Perl suffers from the 'halting problem',"<ref>{{cite web |url=https://metacpan.org/module/PPI |title=PPI—Parse, Analyze and Manipulate Perl (without perl) |last1=Kennedy |first1=Adam |year=2006 |publisher=] |access-date=September 16, 2013 |archive-date=September 3, 2013 |archive-url=https://web.archive.org/web/20130903091241/https://metacpan.org/module/PPI |url-status=live}}</ref> which was later proved.<ref>{{cite journal |title=Rice's Theorem |journal=The Perl Review |volume=4 |issue=3 |pages=23–29 |date=Summer 2008}} and {{cite journal |title=Perl is Undecidable |journal=The Perl Review |volume=5 |pages=7–11 |date=Fall 2008}}, available online at {{cite web |url=http://www.jeffreykegler.com/Home/perl-and-undecidability |title=Perl and Undecidability |last1=Kegler|first1=Jeffrey |access-date=January 4, 2009 |archive-date=August 17, 2009 |archive-url=https://web.archive.org/web/20090817183115/http://www.jeffreykegler.com/Home/perl-and-undecidability |url-status=live}}</ref> | |||
Regular expressions can be dense and cryptic. This is because regular expression syntax is extremely compact, generally using single characters or character pairs to represent its operations. Perl provides some relief from this problem with the <tt>/x</tt> modifer, which allows programmers to place whitespace and comments ''inside'' regular expressions: | |||
Perl is distributed with over 250,000 ] for core Perl language and over 250,000 functional tests for core modules. 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 ]s; further, 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.{{Citation needed|date=December 2020}} | |||
$x =~ m/a # match 'a' | |||
. # match any character | |||
c # match 'c' | |||
/x; | |||
== Ports == | |||
One common use of regular expressions is to specify delimiters for the <tt>split</tt> operator: | |||
<!-- | |||
Perl is available on so many platforms that it makes no sense to keep a long list in this article. List no specific platform unless notable issues exist in running Perl on it. | |||
--> | |||
Perl is ] under both the ] 1.0<ref name="artistic-1.0">{{cite web|url=http://dev.perl.org/licenses/artistic.html|title=The "Artistic License" - dev.perl.org|website=dev.perl.org|access-date=June 24, 2016|archive-date=July 24, 2018|archive-url=https://web.archive.org/web/20180724213601/http://dev.perl.org/licenses/artistic.html|url-status=live}}</ref><ref name="artistic-1.0-git"> {{Webarchive|url=https://web.archive.org/web/20180725033309/http://perl5.git.perl.org/perl.git/blob/HEAD:/Artistic |date=July 25, 2018}} - file on the Perl 5 git repository</ref> and the ].<ref name="licensing">{{cite web |url=http://dev.perl.org/licenses |title=Perl Licensing |access-date=2011-01-08 |publisher=dev.perl.org |archive-date=January 22, 2011 |archive-url=https://web.archive.org/web/20110122175123/http://dev.perl.org/licenses/ |url-status=live}}</ref> Distributions are available for most ]s. It is particularly prevalent on ] and ] systems, but it has been ported to most modern (and many obsolete) platforms. With only six{{citation needed|date=November 2017}} reported exceptions, Perl can be compiled from ] on all ]-compliant, or otherwise-Unix-compatible, platforms.<ref name="cpanports">{{cite web |url=http://www.cpan.org/ports/ |title=Perl Ports (Binary Distributions) |publisher=CPAN.org |last1=Hietaniemi |first1=Jarkko |year=1998 |access-date=April 16, 2006 |archive-date=April 18, 2006 |archive-url=https://web.archive.org/web/20060418115903/http://www.cpan.org/ports/ |url-status=live}}</ref> | |||
@words = split m/,/, $line; # divide $line into comma-separated values | |||
Because of unusual changes required for the ] environment, a special port called MacPerl was shipped independently.<ref name="macperl">{{cite web |url=http://www.macperl.com/ |title=The MacPerl Pages |year=1997 |publisher=Prime Time Freeware |access-date=January 18, 2006 |archive-date=January 18, 2006 |archive-url=https://web.archive.org/web/20060118125208/http://www.macperl.com/ |url-status=live}}</ref> | |||
The <tt>split</tt> operator complements string capture. String capture returns the parts of a string that match a regular expression; <tt>split</tt> returns the parts that don't match. | |||
The ] carries a complete list of supported platforms with links to the distributions available on each.<ref>{{cite web |url=http://www.cpan.org/ports/ |title=Perl Ports (Binary Distributions) |access-date=2011-01-27 |publisher=] |archive-date=April 18, 2006 |archive-url=https://web.archive.org/web/20060418115903/http://www.cpan.org/ports/ |url-status=live}}</ref> CPAN is also the source for publicly available Perl modules that are not part of the core Perl distribution.{{Citation needed|date=December 2020}} | |||
===Database interfaces=== | |||
Perl is widely favored for database applications. Its text handling facilities are good for generating SQL queries; arrays, hashes and automatic memory management make it easy to collect and process the returned data. | |||
ActivePerl is a closed-source distribution from ] that has regular releases that track the core Perl releases.<ref name="activestate">{{cite web |url=http://www.activestate.com/activeperl |title=ActivePerl is Perl for Windows, Mac, Linux, AIX, HP-UX & Solaris |access-date=2011-01-09 |publisher=] Software |archive-url=https://web.archive.org/web/20160331201814/http://www.activestate.com/activeperl |archive-date=March 31, 2016 |url-status=dead}}</ref> The distribution previously included the ] (PPM),<ref name="activestateppm">{{cite web |url=http://docs.activestate.com/activeperl/5.12/faq/ActivePerl-faq2.html |title=Using PPM |access-date=2011-01-09 |publisher=] |archive-date=August 27, 2010 |archive-url=https://web.archive.org/web/20100827110749/http://docs.activestate.com/activeperl/5.12/faq/ActivePerl-faq2.html |url-status=live}}</ref> a popular tool for installing, removing, upgrading, and managing the use of common Perl modules; however, this tool was discontinued as of ActivePerl 5.28.<ref>{{Cite news |last1=Crane |first1=Dana |date=July 23, 2019 |url=https://www.activestate.com/blog/goodbye-ppm-hello-state-tool/ |title=Goodbye PPM, Hello State Tool |website=Activestate.com |access-date=April 16, 2020 |archive-date=July 28, 2020 |archive-url=https://web.archive.org/web/20200728080612/https://www.activestate.com/blog/goodbye-ppm-hello-state-tool/ |url-status=live}}</ref> Included also is ], a ] (WSH) engine implementing the Perl language. ] is an ActiveState tool that adds Perl to the ] ] development suite. A ]-to-Perl converter, a Perl compiler for Windows, and converters of ] and ] to Perl have also been produced by this company and included on the ''ActiveState CD for Windows'', which includes all of their distributions plus the ] and all but the first on the Unix–Linux–POSIX variant thereof in 2002 and afterward.<ref>readme.txt</ref> | |||
In early versions of Perl, database interfaces were created by relinking the interpreter with a client-side database library. This was somewhat clumsy; a particular problem was that the resulting <tt>perl</tt> executable was restricted to using just the one database interface that it was linked to. Also, relinking the interpreter was sufficiently difficult that it was only done for a few of the most important and widely used databases. | |||
== Performance == | |||
In Perl 5, database interfaces are implemented by ] modules. The <tt>DBI</tt> (Database Interface) module presents a single, database-independent interface to Perl applications, while the <tt>DBD::</tt> (Database Driver) modules handle the details of accessing some 50 different databases. There are <tt>DBD::</tt> drivers for most ] ] databases. | |||
] compares the performance of implementations of typical programming problems in several programming languages.<ref>{{cite web |url=http://alioth.debian.org/projects/benchmarksgame/ |title=Alioth: The Computer Language Benchmarks Game: Project Info |access-date=2011-01-13 |publisher=] |archive-url=https://web.archive.org/web/20130325192723/https://alioth.debian.org/projects/benchmarksgame/ |archive-date=March 25, 2013 |url-status=dead |df=mdy-all}}</ref> The submitted Perl implementations typically perform toward the high end of the memory-usage spectrum and give varied speed results. Perl's performance in the benchmarks game is typical for interpreted languages.<ref>{{cite web |url=http://benchmarksgame.alioth.debian.org/u32/which-programs-are-fastest.php?v8=on&lua=on&jruby=on&php=on&python3=on&yarv=on&perl=on |archive-url=https://web.archive.org/web/20130517145336/http://benchmarksgame.alioth.debian.org/u32/which-programs-are-fastest.php?v8=on&lua=on&jruby=on&php=on&python3=on&yarv=on&perl=on |url-status=dead |archive-date=2013-05-17 |title=Which programs are fastest? |access-date=2011-01-13 |work=Computer Language Benchmarks Game |publisher=]}}</ref> | |||
==Language 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 ] 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. | |||
Large Perl programs start more slowly than similar programs in compiled languages because Perl has to compile the source every time it runs. In a talk at the ] conference and subsequent article "A Timely Start", Jean-Louis Leroy found that his Perl programs took much longer to run than expected because the perl interpreter spent significant time finding modules within his over-large include path.<ref>{{cite web |url=http://www.perl.com/pub/a/2005/12/21/a_timely_start.html |title=A Timely Start |last1=Leroy |first1=Jean-Louis |date=2005-12-01 |publisher=O'Reilly |access-date=May 22, 2006 |archive-date=June 13, 2006 |archive-url=https://web.archive.org/web/20060613025623/http://www.perl.com/pub/a/2005/12/21/a_timely_start.html |url-status=live}}</ref> Unlike Java, Python, and Ruby, Perl has only experimental support for pre-compiling.<ref>{{cite web |url=https://metacpan.org/module/NWCLARK/perl-5.8.8/ext/B/B/Bytecode.pm#KNOWN-BUGS |title=B::Bytecode Perl compiler's bytecode backend |author1=Beattie, Malcolm |author2=Enache Adrian |name-list-style=amp |year=2003 |publisher=] |access-date=September 16, 2013 |archive-date=March 30, 2021 |archive-url=https://web.archive.org/web/20210330011632/https://metacpan.org/pod/release/NWCLARK/perl-5.8.8/ext/B/B/Bytecode.pm#KNOWN-BUGS |url-status=dead}}</ref> Therefore, Perl programs pay this overhead penalty on every execution. The run phase of typical programs is long enough that ] startup time is not substantial, but benchmarks that measure very short execution times are likely to be skewed due to this overhead.<ref>{{Cite book|last1=Schwartz|first1=Randal|url=https://books.google.com/books?id=va1PSgaO4xIC&q=Therefore,+Perl+programs+pay+this+overhead+penalty+on+every+execution.+The+run+phase+of+typical+programs+is+long+enough+that+amortized+startup+time+is+not+substantial,+but+benchmarks+that+measure+very+short+execution+times+are+likely+to+be+skewed+due+to+this+overhead.|title=Learning Perl|last2=foy|first2=brian|last3=Phoenix|first3=Tom|date=2011-06-23|publisher="O'Reilly Media, Inc."|isbn=978-1-4493-0358-7|language=en}}</ref> | |||
Perl has many features that ease the programmer's task at the expense of greater CPU and memory requirements. These include automatic memory management; ]; strings, lists, and hashes; regular expressions; introspection and an <tt>eval()</tt> function. | |||
A number of tools have been introduced to improve this situation. The first such tool was Apache's ], which sought to address one of the most-common reasons that small Perl programs were invoked rapidly: ] ] development. ], via Microsoft ], provides similar performance improvements.<ref>{{Cite book|last1=Stein|first1=Lincoln|url=https://books.google.com/books?id=qyzTI_eAeHUC&q=A+number+of+tools+have+been+introduced+to+improve+this+situation.+The+first+such+tool+was+Apache's+mod+perl,+which+sought+to+address+one+of+the+most-common+reasons+that+small+Perl+programs+were+invoked+rapidly:+CGI+Web+development.+ActivePerl,+via+Microsoft+ISAPI,+provides+similar+performance+improvements.|title=Writing Apache Modules with Perl and C: The Apache API and Mod_perl|last2=MacEachern|first2=Doug|date=1999|publisher="O'Reilly Media, Inc."|isbn=978-1-56592-567-0|language=en}}</ref> | |||
Larry Wall was trained as a linguist, and the design of Perl is very much informed by linguistic principles. Examples include ] (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 natural for humans to read and write, even where they complicate the Perl interpreter. | |||
Once Perl code is compiled, there is additional overhead during the execution phase that typically isn't present for programs written in compiled languages such as C or C++. Examples of such overhead include ] interpretation, reference-counting memory management, and dynamic type-checking.<ref>{{Cite book|last1=Bekman|first1=Stas|url=https://books.google.com/books?id=UDabAgAAQBAJ&q=Once+Perl+code+is+compiled,+there+is+additional+overhead+during+the+execution+phase+that+typically+isn't+present+for+programs+written+in+compiled+languages+such+as+C+or+C++.+Examples+of+such+overhead+include+bytecode+interpretation,+reference-counting+memory+management,+and+dynamic+type-checking.|title=Practical Mod_perl|last2=Cholet|first2=Eric|date=2003|publisher="O'Reilly Media, Inc."|isbn=978-0-596-00227-5|language=en}}</ref> | |||
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 like ], where the same ] construct and basic syntax is used for many different purposes. | |||
The most critical routines can be written in other languages (such as ]), which can be connected to Perl via simple Inline modules or the more complex, but flexible, ] mechanism.<ref>{{cite web |url=https://metacpan.org/module/Inline |title=Inline - metacpan.org |access-date=2011-01-26 |last=Ingerson |first=Brian |publisher=] |url-status=dead |archive-url=https://web.archive.org/web/20130613163723/https://metacpan.org/module/Inline |archive-date=June 13, 2013}}</ref> | |||
Perl has features that support a variety of programming paradigms, such as ], ], and ]. At the same time, Perl does not enforce any particular paradigm, or even require the programmer to choose among them. | |||
== Applications == | |||
There is a broad practical bent to both the Perl language and the community and culture that surround it. The preface to '']'' begins, "Perl is a language for getting your job done." One consequence of this is that Perl is not a tidy language. It includes features if people use them, tolerates exceptions to its rules, and employs heuristics to resolve syntactical ambiguities. Discussing the variant behaviour of built-in functions in list and scalar context, the perlfunc(1) man page says, | |||
<blockquote> | |||
In general, they do what you want, unless you want consistency. | |||
</blockquote> | |||
Perl has many and varied applications, compounded by the availability of many standard and third-party modules. | |||
Perl has several mottos that convey aspects of its design and use. One is ''"There's more than one way to do it."'' (TMTOWTDI, usually pronounced 'Tim Toady'). Others are ''"Perl: the Swiss Army Chainsaw of Programming Languages"'' and ''"No unnecessary limits"''. A stated design goal of Perl is to make easy tasks easy and difficult tasks possible. Perl has also been called ''"The Duct Tape of the Internet"''. | |||
Perl has chiefly been used to write ] scripts: large projects written in Perl include ], ], ], ], ], and ]; high-traffic websites that use Perl extensively include ], ],<ref>{{cite book |last1=Gilmore |first1=W. J. |title=Beginning PHP and MySQL: From Novice to Professional, Fourth Edition |year=2010 |url=https://archive.org/details/beginningphpmysq00gilm_240 |url-access=limited |publisher=Apress |page= |isbn=978-1-4302-3114-1}}</ref> ],<ref>{{cite web |title=IMDb Helpdesk: What software/hardware are you using to run the site? |website=Internet Movie Database |url=https://www.imdb.com/help/search?domain=helpdesk_faq&index=1&file=techinfo |access-date=2011-02-12 |archive-date=March 9, 2017 |archive-url=https://web.archive.org/web/20170309083513/http://www.imdb.com/help/search?domain=helpdesk_faq&index=1&file=techinfo |url-status=live}}</ref> ], ],<ref>DuckDuckGo handles a large amount of search queries at 4.5 million queries per day . https://duckduckgo.com/traffic.html {{Webarchive|url=http://webarchive.loc.gov/all/20120215210604/https://duckduckgo.com/traffic.html |date=February 15, 2012}}</ref><ref>DuckDuckGo uses Perl https://web.archive.org/web/20101231135106/http://www.gabrielweinberg.com/blog/2009/03/duck-duck-go-architecture.html</ref> ] and ]. <!-- THIS IS ''not'' A LIST OF EVERY WEBSITE USING PERL. It's a listing of 'high traffic websites'. Please consider traffic volume before adding your own Web site to it. Refs for lesser known websites certainly needed. --> | |||
==Opinion== | |||
It is also an optional component of the popular ] technology stack for ], in lieu of ] or ]. Perl is used extensively as a ] in the ] ] distribution.<ref>{{cite web|url=https://wiki.debian.org/PerlFAQ|title=Perl FAQ|quote=Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there are over 700 packages in unstable that have perl in their name (Mar 2004).|access-date=August 6, 2019|archive-date=August 6, 2019|archive-url=https://web.archive.org/web/20190806111259/https://wiki.debian.org/PerlFAQ|url-status=live}}</ref> | |||
Perl engenders strong feelings among both its proponents and its | |||
detractors. | |||
Perl is often used as a ], tying together systems and interfaces that were not specifically designed to interoperate, and for "]",<ref>{{cite web |url=http://books.perl.org/book/95 |title=Perl Books - Book: Data Munging with Perl |work=Perl.org |access-date=December 30, 2010 |archive-date=September 7, 2011 |archive-url=https://web.archive.org/web/20110907020511/http://books.perl.org/book/95 |url-status=live}}</ref> that is, converting or processing large amounts of data for tasks such as creating reports. These strengths are linked intimately. The combination makes Perl a popular all-purpose language for ]s, particularly because short programs, often called "]s", can be entered and run on a single ].{{Citation needed|date=December 2020}} | |||
===Pro=== | |||
Programmers who like Perl typically cite its power, expressiveness, and ease of use. Perl provides infrastructure for many common programming tasks, such as string and list processing. Other tasks, such as memory management, are handled automatically and transparently. Programmers coming from other languages to Perl often find that whole classes of problems that they have struggled with in the past just don't arise in Perl. As Larry Wall put it, | |||
<blockquote> | |||
What is the sound of Perl? Is it not the sound of a wall that people | |||
have stopped banging their heads against? | |||
</blockquote> | |||
Perl code can be made portable across ] 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.{{Citation needed|date=December 2020}} | |||
Besides its practical benefits, many programmers simply seem to enjoy working in Perl. Early issues of had a page titled "What is Perl?" that concluded: | |||
] and ] are commonly used to add ]s to Perl scripts. | |||
<blockquote> | |||
'''Perl is fun.''' In these days of self-serving jargon, conflicting and unpredictable | |||
standards, and proprietary systems that discourage peeking under the | |||
hood, people have forgotten that programming is supposed to be | |||
fun. I don't mean the satisfaction of seeing our well-tuned programs | |||
do our bidding, but the literary act of creative writing that yields | |||
those programs. With Perl, the journey is as enjoyable as the destination ... | |||
</blockquote> | |||
Perl's text-handling capabilities can be used for generating ] queries; arrays, hashes, and automatic memory management make it easy to collect and process the returned data. For example, in Tim Bunce's ] ] (API), the arguments to the API can be the text of SQL queries; thus it is possible to program in multiple languages at the same time (e.g., for generating a ] using ], ], and SQL in a ]). The use of Perl ] to programmatically customize each of the SQL queries, and the specification of Perl arrays or hashes as the structures to programmatically hold the resulting ]s from each SQL query, allows a high-level mechanism for handling large amounts of data for post-processing by a Perl subprogram.<ref>{{cite book |last=Descartes |first=Alligator |title=Programming the Perl DBI : |year=2000 |publisher=O'Reilly |location=Beijing |isbn=978-1-56592-699-8 |edition=1 |author2=Bunce, Tim |url=https://archive.org/details/programmingperld00desc}}</ref> | |||
Whatever the reasons, there is clearly a broad community of people who are passionate about Perl, as evidenced by the thousands of modules that have been contributed to CPAN, and the hundreds of design proposals that were submitted as ] for Perl 6. | |||
In early versions of Perl, database interfaces were created by relinking the interpreter with a ] database library. This was sufficiently difficult that it was done for only a few of the most-important and most widely used databases, and it restricted the resulting <code>perl</code> executable to using just one database interface at a time.<ref>{{Cite web|title=Perl Programming - Principles of Programming Languages|url=https://sites.google.com/a/principlesofprogram.com/www/perl|access-date=2021-05-18|website=sites.google.com|archive-date=October 8, 2020|archive-url=https://web.archive.org/web/20201008130113/https://sites.google.com/a/principlesofprogram.com/www/perl|url-status=dead}}</ref> | |||
In Perl 5, database interfaces are implemented by Perl DBI modules. The DBI (Database Interface) module presents a single, database-independent interface to Perl applications, while the DBD (Database Driver) modules handle the details of accessing some 50 different databases; there are DBD drivers for most ] ] databases.<ref>{{Cite book|last1=Bunce|first1=Tim|url=https://books.google.com/books?id=WfoOrfuwcb8C&q=The+DBI+(Database+Interface)+module+presents+a+single,+database-independent+interface+to+Perl+applications,+while+the+DBD+(Database+Driver)+modules+handle+the+details+of+accessing+some+50+different+databases;+there+are+DBD+drivers+for+most+ANSI+SQL+databases|title=Programming the Perl DBI: Database programming with Perl|last2=Descartes|first2=Alligator|date=2000-02-04|publisher="O'Reilly Media, Inc."|isbn=978-1-4493-1536-8|language=en}}</ref> | |||
===Con=== | |||
A common complaint is that Perl is ugly. In particular, its prodigious use of punctuation puts off some people; Perl source code is sometimes likened to "line noise". In , ] both acknowledges and responds to this: | |||
DBI provides caching for database handles and queries, which can greatly improve performance in long-lived execution environments such as ],<ref>{{cite web |last=Bekman |first=Stas |title=Efficient Work with Databases under mod_perl |url=http://perl.apache.org/docs/1.0/guide/performance.html#Efficient_Work_with_Databases_under_mod_perl |access-date=2007-09-01 |archive-date=August 22, 2007 |archive-url=https://web.archive.org/web/20070822162513/http://perl.apache.org/docs/1.0/guide/performance.html#Efficient_Work_with_Databases_under_mod_perl |url-status=live}}</ref> helping high-volume systems avert load spikes as in the ].<ref>{{Cite book|last=Pachev|first=Sasha|url=https://books.google.com/books?id=vz6PcTdo8VUC&q=DBI+provides+caching+for+database+handles+and+queries,+which+can+greatly+improve+performance+in+long-lived+execution+environments+such+as+mod+perl,%5B100%5D+helping+high-volume+systems+avert+load+spikes+as+in+the+Slashdot+effect|title=Understanding MySQL Internals: Discovering and Improving a Great Database|date=2007-04-10|publisher="O'Reilly Media, Inc."|isbn=978-0-596-55280-0|language=en}}</ref> | |||
{{cquote| | |||
At the mention of ugly source code, people will of course think of | |||
Perl. But the superficial ugliness of Perl is not the sort I mean. | |||
Real ugliness is not harsh-looking syntax, but having to build | |||
programs out of the wrong concepts. Perl may look like a cartoon character swearing, but there are cases where it surpasses Python conceptually. | |||
}} | |||
In modern Perl applications, especially those written using ]s such as ], the DBI module is often used indirectly via ]s such as ], Class::DBI<ref>{{Cite web|url=https://metacpan.org/pod/Class::DBI|title=Class::DBI - Simple Database Abstraction - metacpan.org|website=metacpan.org|access-date=2020-04-08|archive-date=August 6, 2020|archive-url=https://web.archive.org/web/20200806100410/https://metacpan.org/pod/Class::DBI|url-status=live}}</ref> or Rose::DB::Object<ref>{{Cite web|url=https://metacpan.org/pod/Rose::DB::Object|title=Rose::DB::Object - Extensible, high performance object-relational mapper (ORM). - metacpan.org|website=metacpan.org|access-date=2020-04-08|archive-date=August 6, 2020|archive-url=https://web.archive.org/web/20200806085143/https://metacpan.org/pod/Rose::DB::Object|url-status=live}}</ref> that generate SQL queries and handle data transparently to the application author.<ref>{{Cite web|title=T sql querying developer reference|url=http://pdfpremiumfree.com/download/t-sql-querying-developer-reference-pdf/|access-date=2021-05-18|website=pdfpremiumfree.com|language=en}}</ref> | |||
Another criticism is that Perl is excessively complex and compact, and that it leads to "write-only" code, that is, to code that is virtually impossible to understand after it has been written. It is, of course, possible to write obscure code in any language, but Perl has perhaps more than the usual share of terse, complex and arcane language constructs to exacerbate the problem. Perl supports many such features for backward compatibility, and for use where maintainability is expressly not a concern, such as programs that are entered and run directly on the command line. | |||
== Community == | |||
In a 2003 study titled , Lutz Prechelt wrote: | |||
Perl's culture and community has developed alongside the language itself. ] was the first public venue in which Perl was introduced, but over the course of its evolution, Perl's community was shaped by the growth of broadening Internet-based services including the introduction of the World Wide Web. The community that surrounds Perl was, in fact, the topic of Wall's first "State of the Onion" talk.<ref>{{cite web |url=http://grnlight.net/index.php/programming-articles/100-perl-culture |title=Perl Culture (AKA the first State of the Onion) |first=Larry |last=Wall |author-link=Larry Wall |date=2014-05-22 |access-date=May 22, 2014 |archive-date=May 22, 2014 |archive-url=https://web.archive.org/web/20140522141559/http://grnlight.net/index.php/programming-articles/100-perl-culture |url-status=live}}</ref> | |||
{{cquote| | |||
...the potential uglyness of any aspect of Perl has carefully been balanced with the power that can be derived from it. Nevertheless, Perl makes it relatively easy to shoot oneself in the foot or to produce programs that are very short but also very difficult to understand. For this reason, somewhat like for C++, writing good Perl programs depends more strongly on the knowledge and discipline of the programmer than in most other languages. | |||
}} | |||
State of the Onion is the name for Wall's yearly ]-style summaries on the progress of Perl and its community. They are characterized by his hallmark humor, employing references to Perl's culture, the wider hacker culture, Wall's linguistic background, sometimes his family life, and occasionally even his Christian background.<ref>{{cite web |title=2nd State of the Onion |last1=Wall |first1=Larry |author1-link=Larry Wall |url=http://www.wall.org/~larry/onion/onion.html |access-date=2012-10-12 |archive-date=July 17, 2012 |archive-url=https://web.archive.org/web/20120717014443/http://www.wall.org/~larry/onion/onion.html |url-status=live}} (Search for 'church')</ref> Each talk is first given at various Perl conferences and is eventually also published online. | |||
The free-wheeling language style that delights some Perl programmers concerns and dismays others. For example, the Perl 5 object model does not enforce data security: access to private data is restricted only by convention, not the language itself. An object created in one place may easily be modified in another; there may not be any single place where its state is definitively established. There are techniques for addressing these issues, but they are non-native and little used. | |||
In email, Usenet, and message board postings, "Just another Perl hacker" (JAPH) programs are a common trend, originated by ], one of the earliest professional Perl trainers.<ref>{{cite newsgroup |last1=Schwartz |first1=Randal L. |author1-link=Randal L. Schwartz |title=Who is Just another Perl hacker? |message-id=m1hfpvh2jq.fsf@halfdome.holdit.com |newsgroup=comp.lang.perl.misc |date=1999-05-02 |url=https://groups.google.com/forum/#!msg/comp.lang.perl.misc/nK-lswsaMec/DBL87v4FxOwJ |access-date=December 5, 2014 |archive-date=July 8, 2012 |archive-url=https://archive.today/20120708165748/http://groups.google.com/group/comp.sys.acorn.programmer/browse_thread/thread/b5fd3717bda6a8d0/d4d3e151a783dffa?lnk=gst&q=ioc%23d4d3e151a783dffa#!msg/comp.lang.perl.misc/nK-lswsaMec/DBL87v4FxOwJ |url-status=live}}</ref> In the parlance of Perl culture, Perl programmers are known as Perl hackers, and from this derives the practice of writing short programs to print out the phrase "Just another Perl hacker{{sic|,}}". In the spirit of the original concept, these programs are moderately obfuscated and short enough to fit into the signature of an email or Usenet message. The "canonical" JAPH as developed by Schwartz includes the comma at the end, although this is often omitted.<ref>{{cite web |url=http://www.perlmonks.org/bare/?node_id=443856 |title=Canonical JAPH |access-date=2011-05-16 |last=Schwartz |first=Randal |author-link=Randal L. Schwartz |date=2005-03-31 |publisher=] |archive-date=July 22, 2011 |archive-url=https://web.archive.org/web/20110722055125/http://www.perlmonks.org/bare/?node_id=443856 |url-status=live}}</ref> | |||
There's also criticism of a less technical nature that may be no less important to some. Perl's popularity has declined. As of May, 2006, the of the ten most popular programming languages shows that Perl's popularity is at its lowest since before June, 2001 (the earliest date plotted). In addition, OSCON — the open source convention sponsored by book publisher O'Reilly — is much less Perl-oriented than it used to be. ], author of several Perl books published by O'Reilly, has said that OSCON's organizers are openly hostile to Perl, and that Perl isn't interesting to O'Reilly anymore. | |||
{{Anchor|Perl golf}} | |||
====See also==== | |||
Perl "golf" is the pastime of reducing the number of characters (key "strokes") used in a Perl program to the bare minimum, much in the same way that ] players seek to take as few shots as possible in a round. The phrase's first use<ref name="perl-golf-coined">{{cite newsgroup |last1=Bacon |first1=Greg |title=Re: Incrementing a value in a slice |message-id=7imnti$mjh$1@info2.uah.edu |newsgroup=comp.lang.perl.misc |date=1999-05-28 |url=http://groups.google.com/group/comp.lang.perl.misc/msg/7b97c434492c8d20 |access-date=2011-07-12 |archive-date=July 7, 2011 |archive-url=https://web.archive.org/web/20110707134412/http://groups.google.com/group/comp.lang.perl.misc/msg/7b97c434492c8d20 |url-status=live}}</ref> emphasized the difference between pedestrian code meant to teach a newcomer and terse hacks likely to amuse experienced Perl programmers, an example of the latter being JAPHs that were already used in signatures in Usenet postings and elsewhere. Similar stunts had been an unnamed pastime in the language ] in previous decades. The use of Perl to write a program that performed ] encryption prompted a widespread and practical interest in this pastime.<ref name="rsa">{{cite web |url=http://www.cypherspace.org/rsa/pureperl.html |title=RSA in 5 lines of perl |access-date=2011-01-10 |last=Back |first=Adam |archive-date=January 19, 2011 |archive-url=https://web.archive.org/web/20110119154503/http://www.cypherspace.org/rsa/pureperl.html |url-status=live}}</ref> In subsequent years, the term "]" has been applied to the pastime in other languages.<ref>{{cite web |url=http://codegolf.com/ |title=Code Golf: What is Code Golf? |publisher=29degrees |year=2007 |access-date=November 26, 2018 |archive-url=https://web.archive.org/web/20120113152453/http://codegolf.com/ |archive-date=January 13, 2012 |url-status=dead |df=mdy-all}}</ref> A Perl Golf Apocalypse was held at Perl Conference 4.0 in Monterey, California in July 2000. | |||
— by Shlomi Fish, critic and developer of Perl 6. | |||
As with C, ] competitions were a well known pastime in the late 1990s. The ] was a competition held by ] from 1996 to 2000 that made an arch virtue of Perl's syntactic flexibility. Awards were given for categories such as "most powerful"—programs that made efficient use of space—and "best four-line signature" for programs that fit into four lines of 76 characters in the style of a Usenet ].<ref name="gallo03">{{cite book |last1=Gallo |first1=Felix |title=Games, diversions, and Perl culture: best of the Perl journal |chapter=The Zeroth Obfuscated Perl Contest |editor= Jon Orwant |publisher=O'Reilly Media |year=2003 |chapter-url=http://oreilly.com/catalog/tpj3/chapter/ch43.pdf |access-date=2011-01-12 |url-status=dead |archive-url=https://web.archive.org/web/20091122114544/http://oreilly.com/catalog/tpj3/chapter/ch43.pdf |archive-date=November 22, 2009 |df=mdy-all}}</ref> | |||
==History== | |||
Larry Wall began work on Perl in 1987, and released version 1.0 to the comp.sources.misc ] on ], ]. 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. | |||
Perl poetry is the practice of writing poems that can be compiled as legal Perl code, for example the piece known as "]". Perl poetry is made possible by the large number of English words that are used in the Perl language. New poems are regularly submitted to the community at ].<ref>{{cite web |url=http://www.perlmonks.org/?node_id=1590 |title=Perl Poetry |access-date=2011-01-27 |publisher=] |archive-date=September 27, 2007 |archive-url=https://web.archive.org/web/20070927000904/http://www.perlmonks.org/?node_id=1590 |url-status=live}}</ref> | |||
Until 1991, the only documentation for Perl was a single (increasingly lengthy) ]. In 1991, '']'' (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, Larry Wall abandoned Perl 4 to begin work on Perl 5. Perl 4 remains at version 4.036 to this day. | |||
Development 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 ], ]. It was a nearly complete rewrite of the interpreter, and added many new features to the language, including objects, references, packages, 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. | |||
On ], ], the ] (CPAN) was established. CPAN is a collection of web sites that archive and distribute Perl sources, binary distributions, documentation, scripts, and modules. Originally, each CPAN site had to be accessed through its own URL. Today, the single URL automatically redirects to a CPAN site. | |||
As of 2006, Perl 5 is still being actively maintained. It now includes ] support. The latest stable release is Perl 5.8.8. | |||
==Future== | |||
{{main|Perl 6}} | |||
At the 2000 ], ] made a case for a major new language initiative. This led to a decision to begin work on a redesign of the language, to be called Perl 6. Proposals for new language features were solicited from the Perl community at large, and over 300 RFCs were submitted. | |||
Larry Wall spent the next few years digesting the RFCs and synthesizing them into a coherent framework for Perl 6. He has presented his design for Perl 6 in a series of documents called ]s, which are numbered to correspond to chapters in '']'' ("The Camel Book"). The current, unfinalized specification of Perl 6 is encapsulated in design documents called Synopses, which are numbered to correspond to Apocalypses. | |||
Perl 6 is not intended to be backwards-compatible, though there will be a compatibility mode. | |||
In 2001, it was decided that Perl 6 would run on a cross-language ] called ]. This will mean that other languages targeting the Parrot will gain native access to ] and will allow some level of cross-language development. | |||
In 2005 ] created the ] project, an implementation of Perl 6 in ]. This was and continues to act as a test platform for the Perl 6 language (separate from the development of the actual implementation) allowing the language designers to explore. The pugs project resulted in an active Perl/Haskell cross-language community centred around the ] #perl6 irc channel. | |||
A number of features in the Perl 6 language now show similarities with Haskell, and Perl 6 has been embraced by the Haskell community as a potential scripting language. | |||
As of 2006 Perl 6, Parrot, and pugs are under active development. | |||
==CPAN== | |||
{{main|CPAN}} | |||
], the Comprehensive Perl Archive Network, is a collection of mirrored web sites that serve as a primary archive and distribution channel for Perl sources, distributions, documentation, scripts, and—especially—modules. It is commonly browsed with the search engine . | |||
There are currently over 8,800 modules available on CPAN, contributed by over 2,500 authors. Modules are available for a wide variety of tasks, including advanced mathematics, database connectivity, and networking. Essentially everything on CPAN is freely available; much of the software is licensed under either the ], the ], or both. Anyone can upload software to CPAN via , the Perl Authors Upload Server. | |||
Modules on CPAN can be downloaded and installed by hand. However, it is common for modules to depend on other modules, and following module dependencies by hand can be tedious. Both the module (included in the Perl distribution) and the improved module offer command line installers that understand module dependencies; they can be configured to automatically download and install a module and, recursively, all modules that it requires. | |||
Since many Windows installations don't include a C compiler, Windows users may be limited to pure Perl modules when downloading from CPAN. | |||
==Name== | |||
Perl was originally named "Pearl", after "the pearl of great price" of ] 13:46. Larry Wall wanted to give the language a short name with positive connotations; he claims that he looked at (and rejected) every three- and four-letter word in the dictionary. He also considered naming it after his wife Gloria. Wall discovered before the language's official release that there was already a programming language named ] and changed the spelling of the name. | |||
The name is normally capitalized (''Perl'') when referring to the language and uncapitalized (''perl'') when referring to the interpreter program itself since Unix-like filesystems are case sensitive. Before the release of the first edition of ''Programming Perl'' it was common to refer to the language as ''perl''; ], however, forced the uppercase language name in the book to make the name stand out better when typeset. The case distinction was subsequently adopted by the community. | |||
It is not appropriate to write "PERL", as it is not an ]. The spelling of PERL in all caps is therefore used as a ] for detecting community outsiders. | |||
However, several ]s have been suggested, including the humorous ''Pathologically Eclectic Rubbish Lister''. The more serious ''Practical Extraction and Report Language'' has prevailed in many of today's manuals, including the official Perl man page. It is also consistent with the old name "Pearl": ''Practical Extraction And Report Language''. | |||
===The Camel Symbol=== | |||
Perl is generally symbolized by a camel, which was a result of the picture chosen by camel book publishers ] as the cover picture of ''Programming Perl'', which consequently acquired the name ''The Camel Book''. O'Reilly owns the symbol 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 logos (see above) and buttons. | |||
==Fun with Perl== | |||
As with C, ] competitions are a popular feature of Perl culture. The annual ] makes an arch virtue of Perl's ] flexibility. The following program prints the text "Just another Perl / Unix hacker", using 32 concurrent processes coordinated by pipes. A complete explanation is available on the . | |||
<!-- This code is used with permission. See Talk: page. --> | |||
<nowiki> | |||
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ | |||
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord | |||
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^/&& | |||
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d;sleep rand(2)if/\S/;print</nowiki> | |||
Similar to obfuscated code but with a different purpose, "Perl Poetry" is the practice of writing poems that can actually be compiled by perl. This hobby is more or less unique to Perl due to the large number of regular English words used in the language. New poems are regularly published in the ] site's section. | |||
Another popular pastime is "Perl Golf." As with ], the goal is to reduce the number of strokes that it takes to complete a particular objective, but here "strokes" refers to keystrokes rather than swings of a golf club. A task, such as "scan an input string and return the longest ] that it contains", is proposed and participants try to outdo each other by writing solutions that require fewer and fewer characters of Perl source code. | |||
Another tradition among Perl ]s is writing JAPHs, which are short obfuscated programs that print out the phrase "],". The "canonical" JAPH includes the comma at the end, although this is often omitted, and many variants on the theme have been created (example: , which prints "Just Another Perl Pirate!"). | |||
One interesting Perl module is Lingua::Romana::Perligata. This module translates the source code of a script that uses it from Latin into Perl, allowing the programmer to write executable programs in Latin. | |||
The Perl community has set aside the "]" namespace for modules that are fun or experimental in nature. Some of the Acme modules are deliberately implemented in amusing ways. Some examples: | |||
*, one of the , allows the program's source code to be "whitened" (i.e., all characters replaced with whitespace) and yet still work. This is an example of a ]. There are also a number of other source filters in the Acme namespace. | |||
* simplifies the process of writing a "Hello, World!" program | |||
* allows you to change the "$" prefix for scalar variables to some other character | |||
* is a horribly inefficient way to indicate progress for a task | |||
* satirizes the widely-criticized ] ] service | |||
* implements the logical opposite of the <tt>do</tt> keyword—<tt>don't</tt>, which does not execute the provided block. | |||
==See also== | ==See also== | ||
{{ |
{{Portal|Free and open-source software|Computer programming}} | ||
*] | * ] | ||
*] | * ] | ||
*] | * ] | ||
*] | * ] | ||
*]- the Perl Object Environment | |||
*]- the Perl Data Language | |||
*] | |||
*] | |||
*] | |||
*] | |||
==References== | ==References== | ||
{{Reflist}} | |||
===Books=== | |||
{{book}} | |||
==Further reading== | |||
*] (the ''Camel book''), ISBN 0-596-00027-8 | |||
* |
* 6th Edition (2011), O'Reilly. Beginner-level introduction to Perl. | ||
* 1st Edition (2012), Wrox. A beginner's tutorial for those new to programming or just new to Perl. | |||
*], ISBN 0-596-00313-7 | |||
* {{Webarchive|url=https://web.archive.org/web/20111222045417/http://onyxneon.com/books/modern_perl/ |date=December 22, 2011}} 2nd Edition (2012), Onyx Neon. Describes Modern Perl programming techniques. | |||
(Also see <i>Books</i> under <i>External links</i>, below.) | |||
* 4th Edition (2012), O'Reilly. The definitive Perl reference. | |||
* 2nd Edition (2010), Addison-Wesley. Intermediate- to advanced-level guide to writing idiomatic Perl. | |||
===Perl man pages=== | |||
* '']'', {{ISBN|0-596-00313-7}}. Practical Perl programming examples. | |||
The Perl man pages are included in the Perl . They are available on the web from http://perldoc.perl.org/. Some good starting points are: | |||
* {{cite book |last=Dominus |first=Mark Jason |title=Higher Order Perl |url=http://hop.perl.plover.com/book/ |year=2005 |publisher=Morgan Kaufmann |isbn=978-1-55860-701-9}} Functional programming techniques in Perl. | |||
*- a brief introduction and overview of Perl | |||
*- Perl syntax | |||
*- Perl regular expressions | |||
*- what is new for perl v5.''x''.''y'' | |||
===Web pages=== | |||
* | |||
* | |||
==External links== | ==External links== | ||
{{Sister project links|commons=Category:Perl (programming language)|v=Topic:Perl|n=no|q=Perl|s=no|b=Perl Programming}} | |||
===Major Resources=== | |||
<!--======== {{No more links}} ======== | |||
* – The Perl Directory | |||
PLEASE BE CAUTIOUS IN ADDING MORE LINKS TO THIS ARTICLE. Misplaced Pages is not a collection of links and must not be used for advertising. | |||
* – Perl on ] | |||
* – online Perl documentation | |||
Excessive or inappropriate links WILL BE DELETED. See ] & ] for details. | |||
===Development=== | |||
* | |||
* | |||
* | |||
* – Perl 5 running on top of Parrot | |||
* – Perl 6 running on top of Haskell | |||
If there are already plentiful links, please propose additions or replacements on this article's discussion page, or submit your link to the relevant category at the Curlie directory (Curlie.org) and link back to that category using the {{Curlie}} template. | |||
===Books=== | |||
* books.perl.org | |||
* | |||
* - A collection of Perl books available for free download. | |||
(Also see <i>Books</i> under <i>References</i>, above.) | |||
Before adding any links, be sure you have read the External Links style guide. Then stop and reread it again. If you aren't absolutely sure the link is in compliance, ask on the talk page first! | |||
===Support=== | |||
See http://en.wikipedia.org/Wikipedia:External_links/Noticeboard#.27Perl.27_external_links | |||
*User groups | |||
--> | |||
** – local user groups in cities worldwide | |||
* {{Official website}} | |||
** – ]-affiliated discussion forum and resources | |||
** – Perl news and community discussion | |||
{{Perl|state=expanded}} | |||
===Distributions=== | |||
{{Programming languages}} | |||
* – Comprehensive Perl Archive Network, Perl source distribution | |||
{{FOSS}} | |||
* – Perl for ] and many other platforms | |||
{{Authority control}} | |||
* – another distribution of Perl for Microsoft Windows | |||
* also distributes Perl on Windows | |||
] | |||
===History=== | |||
] | |||
* | |||
] | |||
* – "Stability. Speed. Simplicity. perl1 is here." | |||
] | |||
* | |||
] | |||
] | |||
===Humor=== | |||
] | |||
* | |||
] | |||
* | |||
] | |||
* | |||
] | |||
* | |||
] | |||
* | |||
] | |||
===Miscellaneous=== | |||
* in the ] | |||
* - print magazine about Perl | |||
* online only magazine about Perl | |||
* | |||
* - Perl Podcast | |||
* - O'Reilly | |||
* | |||
*Google Video: Beginning Perl for Nonprogrammers | |||
* - a large package of Perl modules used for ] | |||
{{Major programming languages small}} | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | ] | ||
] | ] | ||
] | ] | ||
] | |||
] | ] | ||
] | ] | ||
<!-- Hidden categories below --> | |||
] | |||
<!-- Interwiki finder http://vs.aka-online.de/globalwpsearch/ --> | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
] | |||
<!-- END OF PAGE --> |
Latest revision as of 04:13, 24 November 2024
Interpreted programming language first released in 1987 For other uses, see Perl (disambiguation). Not to be confused with PEARL (programming language).
Paradigm | Multi-paradigm |
---|---|
Designed by | Larry Wall |
Developer | Larry Wall |
First appeared | December 18, 1987; 37 years ago (1987-12-18) |
Stable release |
|
Preview release | 5.41.3 / 29 August 2024; 3 months ago (2024-08-29) |
Typing discipline | Dynamic |
Implementation language | C |
OS | Cross-platform |
License | Artistic 1.0 or GNU General Public License version 1 or any later version |
Filename extensions | .plx, .pls, .pl, .pm, .xs, .t, .pod, .cgi, .psgi |
Website | perl.org |
Influenced by | |
AWK, BASIC, C, C++, Lisp, sed, Unix shell | |
Influenced | |
CoffeeScript, Groovy, JavaScript, Julia, LPC, PHP, Python, Raku, Ruby, PowerShell | |
|
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was 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. Perl originally was not capitalized and the name was changed to being capitalized by the time Perl 4 was released. The latest release is Perl 5, first released in 1994. From 2000 to October 2019 a sixth version of Perl was in development; the sixth version's name was changed to Raku. Both languages continue to be developed independently by different development teams which liberally borrow ideas from each other.
Perl borrows features from other programming languages including C, sh, AWK, and sed. It provides text processing facilities without the arbitrary data-length limits of many contemporary Unix command line tools. Perl is a highly expressive programming language: source code for a given algorithm can be short and highly compressible.
Perl gained widespread popularity in the mid-1990s as a CGI scripting language, in part due to its powerful 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 graphical user interfaces (GUIs). It has been nicknamed "the Swiss Army chainsaw of scripting languages" because of its flexibility and power. 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.
Name and logos
The Camel symbol used by O'Reilly MediaThe onion logo used by The Perl FoundationPerl was originally named "Pearl". Wall wanted to give the language a short name with positive connotations. It is also a Christian reference to the Parable of the Pearl from the Gospel of Matthew. However, Wall discovered the existing PEARL language before Perl's official release and dropped the "a" from the name.
The name is occasionally expanded as a backronym: Practical Extraction and Report Language and Wall's own Pathologically Eclectic Rubbish Lister, which is in the manual page for perl.
Programming Perl, published by O'Reilly Media, features a picture of a dromedary camel on the cover and is commonly called the "Camel Book". This image has become an unofficial symbol of Perl. O'Reilly owns the image as a trademark but licenses it for non-commercial use, requiring only an acknowledgement and a link to www.perl.com. Licensing for commercial use is decided on a case-by-case basis. O'Reilly also provides "Programming Republic of Perl" logos for non-commercial sites and "Powered by Perl" buttons for any site that uses Perl.
The Perl Foundation owns an alternative symbol, an onion, which it licenses to its subsidiaries, Perl Mongers, PerlMonks, Perl.org, and others. The symbol is a visual pun on pearl onion.
History
Early versions
Larry Wall began work on Perl in 1987, while employed as a programmer at Unisys; he released version 1.0 on December 18, 1987. Wall based early Perl on some methods existing languages used for text manipulation.
Perl 2, released in June 1988, featured a better regular expression engine. Perl 3, released in October 1989, added support for binary data streams.
1990s
Main article: Perl 5 version historyOriginally, the only documentation for Perl was a single lengthy man page. In 1991, Programming Perl, known to many Perl programmers as the "Camel Book" because of its cover, 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 well documented by the book. Perl 4 was released in March 1991.
Perl 4 went through a series of maintenance releases, culminating in Perl 4.036 in 1993, whereupon 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.000 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 (my) 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 has been in active development since then.
Perl 5.001 was released on March 13, 1995. Perl 5.002 was released on February 29, 1996 with the new prototypes feature. This allowed module authors to make subroutines that behaved like Perl builtins. Perl 5.003 was released June 25, 1996, as a security release.
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 the Perl language and Perl modules; as of December 2022, it carries over 211,850 modules in 43,865 distributions, written by more than 14,324 authors, and is mirrored worldwide at more than 245 locations.
Perl 5.004 was released on May 15, 1997, and included, among other things, the UNIVERSAL package, giving Perl a base object from which all classes were automatically derived and the ability to require versions of modules. Another significant development was the inclusion of the CGI.pm module, which contributed to Perl's popularity as a CGI scripting language.
Perl 5.004 added support for Microsoft Windows, Plan 9, QNX, and AmigaOS.
Perl 5.005 was released on July 22, 1998. This release included several enhancements to the regex engine, new hooks into the backend through the B::*
modules, the qr//
regex quote operator, a large selection of other new core modules, and added support for several more operating systems, including BeOS.
2000–2020
Major version | Latest update | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Old version, no longer maintained: 5.4 | 1999-04-29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.5 | 2004-02-23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.6 | 2003-11-15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.8 | 2008-12-14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.10 | 2009-08-22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.12 | 2012-11-10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.14 | 2013-03-10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.16 | 2013-03-11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.18 | 2014-10-01 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.20 | 2015-09-12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.22 | 2017-07-15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.24 | 2018-04-14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.26 | 2018-11-29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.28 | 2020-06-01 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.30 | 2020-06-01 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.32 | 2021-01-23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.34 | 2023-11-29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, no longer maintained: 5.36 | 2023-11-29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Old version, yet still maintained: 5.38 | 2023-11-29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Current stable version: 5.40 | 2024-06-09 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Legend: Old version Old version, still maintained Current stable version Latest preview version Future release |
Perl 5.6 was released on March 22, 2000. Major changes included 64-bit support, Unicode string representation, support for files over 2 GiB, and the "our" keyword. When developing Perl 5.6, the decision was made to switch the versioning scheme to one more similar to other open source projects; after 5.005_63, the next version became 5.5.640, with plans for development versions to have odd numbers and stable versions to have even numbers.
In 2000, Wall put forth a call for suggestions for a new version of Perl from the community. The process resulted in 361 RFC (Request for Comments) documents that were to be used in guiding development of Perl 6. In 2001, work began on the "Apocalypses" for Perl 6, a series of documents meant to summarize the change requests and present the design of the next generation of Perl. They were presented as a digest of the RFCs, rather than a formal document. At this time, Perl 6 existed only as a description of a language.
Perl 5.8 was first released on July 18, 2002, and further 5.X versions have been released approximately yearly since then. Perl 5.8 improved Unicode support, added a new I/O implementation, added a new thread implementation, improved numeric accuracy, and added several new modules. As of 2013, this version was still the most popular Perl version and was used by Red Hat Linux 5, SUSE Linux 10, Solaris 10, HP-UX 11.31, and AIX 5.
In 2004, work began on the "Synopses" – documents that originally summarized the Apocalypses, but which became the specification for the Perl 6 language. In February 2005, Audrey Tang began work on Pugs, a Perl 6 interpreter written in Haskell. This was the first concerted effort toward making Perl 6 a reality. This effort stalled in 2006.
The Perl On New Internal Engine (PONIE) project existed from 2003 until 2006. It was to be a bridge between Perl 5 and 6, and an effort to rewrite the Perl 5 interpreter to run on the Perl 6 Parrot virtual machine. The goal was to ensure the future of the millions of lines of Perl 5 code at thousands of companies around the world. The PONIE project ended in 2006 and is no longer being actively developed. Some of the improvements made to the Perl 5 interpreter as part of PONIE were folded into that project.
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. These included a switch statement (called "given"/"when"), regular expressions updates, and the smart match operator (~~). Around this same time, development began in earnest on another implementation of Perl 6 known as Rakudo Perl, developed in tandem with the Parrot virtual machine. As of November 2009, Rakudo Perl has had regular monthly releases and now is the most complete implementation of Perl 6.
A major change in the development process of Perl 5 occurred with Perl 5.11; the development community has switched to a monthly release cycle of development releases, with a yearly schedule of stable releases. By that plan, bugfix point releases will follow the stable releases every three months.
On April 12, 2010, Perl 5.12.0 was released. Notable core enhancements include new package NAME VERSION
syntax, the yada yada operator (intended to mark placeholder code that is not yet implemented), implicit strictures, full Y2038 compliance, regex conversion overloading, DTrace support, and Unicode 5.2.
On May 14, 2011, Perl 5.14 was released with JSON support built-in.
On May 20, 2012, Perl 5.16 was released. Notable new features include the ability to specify a given version of Perl that one wishes to emulate, allowing users to upgrade their version of Perl, but still run old scripts that would normally be incompatible. Perl 5.16 also updates the core to support Unicode 6.1.
On May 18, 2013, Perl 5.18 was released. Notable new features include the new dtrace hooks, lexical subs, more CORE:: subs, overhaul of the hash for security reasons, support for Unicode 6.2.
On May 27, 2014, Perl 5.20 was released. Notable new features include subroutine signatures, hash slices/new slice syntax, postfix dereferencing (experimental), Unicode 6.3, and a rand() function using a consistent random number generator.
Some observers credit the release of Perl 5.10 with the start of the Modern Perl movement. In particular, this phrase describes a style of development that embraces the use of the CPAN, takes advantage of recent developments in the language, and is rigorous about creating high quality code. While the book Modern Perl may be the most visible standard-bearer of this idea, other groups such as the Enlightened Perl Organization have taken up the cause.
In late 2012 and 2013, several projects for alternative implementations for Perl 5 started: Perl5 in Perl6 by the Rakudo Perl team, moe by Stevan Little and friends, p2 by the Perl11 team under Reini Urban, gperl by goccy, and rperl, a Kickstarter project led by Will Braswell and affiliated with the Perl11 project.
Perl 6 and Raku
Main article: Raku (programming language)At the 2000 Perl Conference, Jon Orwant made a case for a major new language initiative. This led to a decision to begin work on a redesign of the language, to be called Perl 6. Proposals for new language features were solicited from the Perl community at large, which submitted more than 300 RFCs.
Wall spent the next few years digesting the RFCs and synthesizing them into a coherent framework for Perl 6. He presented his design for Perl 6 in a series of documents called "apocalypses" – numbered to correspond to chapters in Programming Perl. As of January 2011, the developing specification of Perl 6 was encapsulated in design documents called Synopses – numbered to correspond to Apocalypses.
Thesis work by Bradley M. Kuhn, overseen by Wall, considered the possible use of the Java virtual machine as a runtime for Perl. Kuhn's thesis showed this approach to be problematic. In 2001, it was decided that Perl 6 would run on a cross-language virtual machine called Parrot.
In 2005, Audrey Tang created the Pugs project, an implementation of Perl 6 in Haskell. This acted as, and continues to act as, a test platform for the Perl 6 language (separate from the development of the actual implementation), allowing the language designers to explore. The Pugs project spawned an active Perl/Haskell cross-language community centered around the Libera Chat #raku IRC channel. Many functional programming influences were absorbed by the Perl 6 design team.
In 2012, Perl 6 development was centered primarily on two compilers:
- Rakudo, an implementation running on the Parrot virtual machine and the Java virtual machine.
- Niecza, which targets the Common Language Runtime.
In 2013, MoarVM ("Metamodel On A Runtime"), a C language-based virtual machine designed primarily for Rakudo was announced.
In October 2019, Perl 6 was renamed to Raku.
As of 2017 only the Rakudo implementation and MoarVM are under active development, and other virtual machines, such as the Java Virtual Machine and JavaScript, are supported.
Perl 7
In June 2020, Perl 7 was announced as the successor to Perl 5. Perl 7 was to initially be based on Perl 5.32 with a release expected in first half of 2021, and release candidates sooner.
This plan was revised in May 2021, without any release timeframe or version of Perl 5 for use as a baseline specified. When Perl 7 would be released, Perl 5 would have gone into long term maintenance. Supported Perl 5 versions however would continue to get important security and bug fixes.
Perl 7 was announced on 24 June 2020 at "The Perl Conference in the Cloud" as the successor to Perl 5. Based on Perl 5.32, Perl 7 was planned to be backward compatible with modern Perl 5 code; Perl 5 code, without boilerplate (pragma) header needs adding use compat::perl5;
to stay compatible, but modern code can drop some of the boilerplate.
The plan to go to Perl 7 brought up more discussion, however, and the Perl Steering Committee canceled it to avoid issues with backward compatibility for scripts that were not written to the pragmas and modules that would become the default in Perl 7. Perl 7 will only come out when the developers add enough features to warrant a major release upgrade.
Design
Main article: Perl language structurePhilosophy
According to Wall, Perl has two slogans. The first is "There's more than one way to do it," commonly known as TMTOWTDI, (pronounced Tim Toady). As proponents of this motto argue, this philosophy makes it easy to write concise statements.
The second slogan is "Easy things should be easy and hard things should be possible".
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, aimed to make efficient use of expensive computer hardware. In contrast, Perl was designed so that computer programmers could write programs more quickly and easily.
Perl has many features that ease the task of the programmer 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. Perl follows the theory of "no built-in limits", an idea similar to the Zero One Infinity rule.
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 write, even where they complicate the Perl interpreter.
Perl's 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.
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. Perl's function documentation remarks on the variant behavior of built-in functions in list and scalar contexts by saying, "In general, they do what you want, unless you want consistency."
Features
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
). 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 hashes ("associative arrays") from AWK and regular expressions from sed. These simplify many parsing, text-handling, and data-management tasks. Shared with Lisp is the implicit return of the last value in a block, and all statements are also expressions which 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.
Syntax
Perl has been referred to as "line noise" and a "write-only language" by its critics. Randal L. Schwartz in the first edition of the book Learning Perl, in the first chapter states: "Yes, sometimes Perl looks like line noise to the uninitiated, but to the seasoned Perl programmer, it looks like checksummed line noise with a mission in life." He also stated that the accusation that Perl is a write-only language could be avoided by coding with "proper care". The Perl overview document perlintro states that the names of built-in "magic" scalar variables "look like punctuation or line noise". However, the English module provides both long and short English alternatives. perlstyle document states that line noise in regular expressions could be mitigated using the /x
modifier to add whitespace.
According to the Perl 6 FAQ, Perl 6 was designed to mitigate "the usual suspects" that elicit the "line noise" claim from Perl 5 critics, including the removal of "the majority of the punctuation variables" and the sanitization of the regex syntax. The Perl 6 FAQ also states that what is sometimes referred to as Perl's line noise is "the actual syntax of the language" just as gerunds and prepositions are a part of the English language. In a December 2012 blog posting, despite claiming that "Rakudo Perl 6 has failed and will continue to fail unless it gets some adult supervision", chromatic stated that the design of Perl 6 has a "well-defined grammar", an "improved type system, a unified object system with an intelligent metamodel, metaoperators, and a clearer system of context that provides for such niceties as pervasive laziness". He also stated that "Perl 6 has a coherence and a consistency that Perl 5 lacks."
In Perl, one could write the "Hello, World!" program as:
print "Hello, World!\n";
Here is a more complex Perl program, that counts down seconds from a given starting value:
#!/usr/bin/perl use strict; use warnings; my ( $remaining, $total ); $remaining=$total=shift(@ARGV); STDOUT->autoflush(1); while ( $remaining ) { printf ( "Remaining %s/%s \r", $remaining--, $total ); sleep 1; } print "\n";
The Perl interpreter can also be used for one-off scripts on the command line. The following example (as invoked from an sh-compatible shell, such as Bash) translates the string "Bob" in all files ending with .txt in the current directory to "Robert":
$ perl -i.bak -lp -e 's/Bob/Robert/g' *.txt
Implementation
No written specification or standard for the Perl language exists for Perl versions through Perl 5, 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. Perl 6, however, started with a specification, and several projects aim to implement some or all of the specification.
Perl is implemented as a core interpreter, written in C, together with a large collection of modules, written in Perl and C. As of 2010, 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.
The life of a Perl interpreter divides broadly into a compile phase and a run phase. In Perl, the phases are the major stages in the interpreter's life-cycle. Each interpreter goes through each phase only once, and the phases follow in a fixed sequence.
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 is a longstanding 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.
Other programs that undertake to parse Perl, such as source-code analyzers and auto-indenters, have to contend not only with ambiguous syntactic constructs but also with the undecidability of Perl parsing in the general case. Adam Kennedy's PPI project focused on parsing Perl code as a document (retaining its integrity as a document), instead of parsing Perl as executable code (that not even Perl itself can always do). It was Kennedy who first conjectured that "parsing Perl suffers from the 'halting problem'," which was later proved.
Perl is distributed with over 250,000 functional tests for core Perl language and over 250,000 functional tests for core modules. 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 software bugs; further, 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.
Ports
Perl is dual licensed under both the Artistic License 1.0 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 POSIX-compliant, or otherwise-Unix-compatible, platforms.
Because of unusual changes required for the classic Mac OS 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 is also the source for publicly available Perl modules that are not part of the core Perl distribution.
ActivePerl is a closed-source distribution from ActiveState that has regular releases that track the core Perl releases. The distribution previously included the Perl package manager (PPM), a popular tool for installing, removing, upgrading, and managing the use of common Perl modules; however, this tool was discontinued as of ActivePerl 5.28. Included also is PerlScript, a Windows Script Host (WSH) engine implementing the Perl language. Visual Perl is an ActiveState tool that adds Perl to the Visual Studio .NET development suite. A VBScript-to-Perl converter, a Perl compiler for Windows, and converters of AWK and sed to Perl have also been produced by this company and included on the ActiveState CD for Windows, which includes all of their distributions plus the Komodo IDE and all but the first on the Unix–Linux–POSIX variant thereof in 2002 and afterward.
Performance
The Computer Language Benchmarks Game compares the performance of implementations of typical programming problems in several programming languages. The submitted Perl implementations typically perform toward the high end of the memory-usage spectrum and give varied speed results. Perl's performance in the benchmarks game is typical for interpreted languages.
Large Perl programs start more slowly than similar programs in compiled languages because Perl has to compile the source every time it runs. In a talk at the YAPC::Europe 2005 conference and subsequent article "A Timely Start", Jean-Louis Leroy found that his Perl programs took much longer to run than expected because the perl interpreter spent significant time finding modules within his over-large include path. Unlike Java, Python, and Ruby, Perl has only experimental support for pre-compiling. Therefore, Perl programs pay this overhead penalty on every execution. The run phase of typical programs is long enough that amortized startup time is not substantial, but benchmarks that measure very short execution times are likely to be skewed due to this overhead.
A number of tools have been introduced to improve this situation. The first such tool was Apache's mod_perl, which sought to address one of the most-common reasons that small Perl programs were invoked rapidly: CGI Web development. ActivePerl, via Microsoft ISAPI, provides similar performance improvements.
Once Perl code is compiled, there is additional overhead during the execution phase that typically isn't present for programs written in compiled languages such as C or C++. Examples of such overhead include bytecode interpretation, reference-counting memory management, and dynamic type-checking.
The most critical routines can be written in other languages (such as C), which can be connected to Perl via simple Inline modules or the more complex, but flexible, XS mechanism.
Applications
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 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. These strengths are linked intimately. 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 commercial off-the-shelf (COTS) and bespoke) to simplify packaging and maintenance of software build- and deployment-scripts.
Perl/Tk and wxPerl are commonly used to add graphical user interfaces to Perl scripts.
Perl's text-handling capabilities can be used for generating SQL queries; arrays, hashes, and automatic memory management make it easy to collect and process the returned data. For example, in Tim Bunce's Perl DBI application programming interface (API), the arguments to the API can be the text of SQL queries; thus it is possible to program in multiple languages at the same time (e.g., for generating a Web page using HTML, JavaScript, and SQL in a here document). The use of Perl variable interpolation to programmatically customize each of the SQL queries, and the specification of Perl arrays or hashes as the structures to programmatically hold the resulting data sets from each SQL query, allows a high-level mechanism for handling large amounts of data for post-processing by a Perl subprogram.
In early versions of Perl, database interfaces were created by relinking the interpreter with a client-side database library. This was sufficiently difficult that it was done for only a few of the most-important and most widely used databases, and it restricted the resulting perl
executable to using just one database interface at a time.
In Perl 5, database interfaces are implemented by Perl DBI modules. The DBI (Database Interface) module presents a single, database-independent interface to Perl applications, while the DBD (Database Driver) modules handle the details of accessing some 50 different databases; there are DBD drivers for most ANSI SQL databases.
DBI provides caching for database handles and queries, which can greatly improve performance in long-lived execution environments such as mod_perl, helping high-volume systems avert load spikes as in the Slashdot effect.
In modern Perl applications, especially those written using web frameworks such as Catalyst, the DBI module is often used indirectly via object-relational mappers such as DBIx::Class, Class::DBI or Rose::DB::Object that generate SQL queries and handle data transparently to the application author.
Community
Perl's culture and community has developed alongside the language itself. Usenet was the first public venue in which Perl was introduced, but over the course of its evolution, Perl's community was shaped by the growth of broadening Internet-based services including the introduction of the World Wide Web. The community that surrounds Perl was, in fact, the topic of Wall's first "State of the Onion" talk.
State of the Onion is the name for Wall's yearly keynote-style summaries on the progress of Perl and its community. They are characterized by his hallmark humor, employing references to Perl's culture, the wider hacker culture, Wall's linguistic background, sometimes his family life, and occasionally even his Christian background. Each talk is first given at various Perl conferences and is eventually also published online.
In email, Usenet, and message board postings, "Just another Perl hacker" (JAPH) programs are a common trend, originated by Randal L. Schwartz, one of the earliest professional Perl trainers. In the parlance of Perl culture, Perl programmers are known as Perl hackers, and from this derives the practice of writing short programs to print out the phrase "Just another Perl hacker, [sic]". In the spirit of the original concept, these programs are moderately obfuscated and short enough to fit into the signature of an email or Usenet message. The "canonical" JAPH as developed by Schwartz includes the comma at the end, although this is often omitted.
Perl "golf" is the pastime of reducing the number of characters (key "strokes") used in a Perl program to the bare minimum, much in the same way that golf players seek to take as few shots as possible in a round. The phrase's first use emphasized the difference between pedestrian code meant to teach a newcomer and terse hacks likely to amuse experienced Perl programmers, an example of the latter being JAPHs that were already used in signatures in Usenet postings and elsewhere. Similar stunts had been an unnamed pastime in the language APL in previous decades. The use of Perl to write a program that performed RSA encryption prompted a widespread and practical interest in this pastime. In subsequent years, the term "code golf" has been applied to the pastime in other languages. A Perl Golf Apocalypse was held at Perl Conference 4.0 in Monterey, California in July 2000.
As with C, obfuscated code competitions were a well known pastime in the late 1990s. The Obfuscated Perl Contest was a competition held by The Perl Journal from 1996 to 2000 that made an arch virtue of Perl's syntactic flexibility. Awards were given for categories such as "most powerful"—programs that made efficient use of space—and "best four-line signature" for programs that fit into four lines of 76 characters in the style of a Usenet signature block.
Perl poetry is the practice of writing poems that can be compiled as legal Perl code, for example the piece known as "Black Perl". Perl poetry is made possible by the large number of English words that are used in the Perl language. New poems are regularly submitted to the community at PerlMonks.
See also
References
- ^ Ashton, Elaine (1999). "The Timeline of Perl and its Culture (v3.0_0505)". Archived from the original on January 11, 2013. Retrieved March 12, 2004.
- "Perl v5.40.0 is now available". www.nntp.perl.org. Retrieved June 11, 2024.
- "Perl 5.34.3, Perl 5.36.3 and Perl 5.38.2 are now available". www.nntp.perl.org. Retrieved December 5, 2023.
- "Release announcement for perl v5.41.3". www.nntp.perl.org. Retrieved August 29, 2024.
- ^ "The "Artistic License" - dev.perl.org". dev.perl.org. Archived from the original on July 24, 2018. Retrieved June 24, 2016.
- ^ Artistic Archived July 25, 2018, at the Wayback Machine - file on the Perl 5 git repository
- ^ "Perl Licensing". dev.perl.org. Archived from the original on January 22, 2011. Retrieved January 8, 2011.
- Wall, Larry (December 12, 2007). "Programming is Hard, Let's Go Scripting..." Archived from the original on July 28, 2017. Retrieved April 14, 2019.
All language designers have their occasional idiosyncracies. I'm just better at it than most.
- Lapworth, Leo. "General Questions About Perl". Perl FAQ. Perl.org. Archived from the original on May 28, 2013. Retrieved February 24, 2012.
- "perl(1): Practical Extraction/Report Language - Linux man page". Linux.die.net. Archived from the original on June 3, 2013. Retrieved July 23, 2013.
- ^ Long, Tony. "Dec. 18, 1987: Perl Simplifies the Labyrinth That Is Programming Language". Wired. ISSN 1059-1028. Retrieved February 14, 2023.
- Sheppard, Doug (October 16, 2000). "Beginner's Introduction to Perl". dev.perl.org. Archived from the original on June 5, 2011. Retrieved January 8, 2011.
- ^ "Larry Wall, the Guru of Perl". Linux Journal. Retrieved August 30, 2023.
- "About Perl". perl.org. Archived from the original on November 6, 2015. Retrieved April 20, 2013.
"Perl" is a family of languages, "Perl 6" is part of the family, but it is a separate language that has its own development team. Its existence has no significant impact on the continuing development of "Perl 5".
- "Path to Raku". GitHub. Archived from the original on November 12, 2020. Retrieved January 14, 2021.
This document describes the steps to be taken to effectuate a rename of Perl 6 to Raku
- ^ Wall, Larry; Christiansen, Tom; Orwant, Jon (July 2000). Programming Perl, Third Edition. O'Reilly Media. ISBN 978-0-596-00027-1.
- "How programs are measured". Computer Language Benchmarks Game, Debian.net. Archived from the original on July 12, 2020. Retrieved October 5, 2020.
- "RSA in 3 lines of perl - Everything2.com". everything2.com. Archived from the original on October 8, 2020. Retrieved October 5, 2020.
- "Language Evaluations". Archived from the original on March 10, 2015. Retrieved January 30, 2015.
Perl's strongest point is its extremely powerful built-in facilities for pattern-directed processing of textual, line-oriented data formats; it is unsurpassed at this.
- "You Used Perl to Write WHAT?!". January 24, 2008. Archived from the original on February 4, 2015. Retrieved February 4, 2015.
perl has always been the go-to language for any task that involves pattern-matching input
- "The Importance of Perl". Archived from the original on February 2, 2015. Retrieved February 4, 2015.
Perl's unparalleled ability to process text...
- Smith, Roderick W. (June 21, 2002). Advanced Linux Networking. Addison-Wesley Professional. p. 594. ISBN 978-0-201-77423-8.
- Sheppard, Doug (October 16, 2000). "Beginner's Introduction to Perl". O'Reilly Media. Archived from the original on June 4, 2008. Retrieved July 27, 2008.
- Leonard, Andrew. "The joy of Perl". Salon.com. Archived from the original on July 6, 2012. Retrieved June 5, 2012.
- "Scripting on the Lido Deck". Wired. March 7, 2016. Archived from the original on March 7, 2016. Retrieved February 14, 2023.
- Richardson, Marjorie (May 1, 1999). "Larry Wall, the Guru of Perl". Linux Journal. Archived from the original on July 20, 2013. Retrieved January 3, 2011.
- Schwartz, Randal; foy, brian; Phoenix, Tom (June 16, 2011). Learning Perl. O'Reilly Media, Inc. p. 4. ISBN 978-1449313142.
Perl is sometimes called the "Practical Extraction and Report Language", although it has also been called a "Pathologically Eclectic Rubbish Lister", among other expansions. It's actually a backronym, not an acronym, since Larry Wall, Perl's creator, came up with the name first and the expansion later. That's why 'Perl' isn't in all caps. There's no point in arguing that expansion is correct: Larry endorses both.
- Wall, Larry. "perl - The Perl language interpreter". Perl 5 version 12.2 documentation. Archived from the original on July 1, 2013. Retrieved January 26, 2011.
- ^ Schwartz, Randal L; Phoenix, Tom; Foy, Brian (December 6, 2007). Learning Perl, Third Edition. O'Reilly Media. ISBN 978-0-596-00132-2.
- ^ "The Perl Camel Usage and Trademark Information". O'Reilly Media. Archived from the original on April 25, 2018. Retrieved January 9, 2011.
- "Perl Trademark". The Perl Foundation. Archived from the original on May 3, 2011. Retrieved January 9, 2011.
- Gillmore, Dan (October 25, 1998). "Republic Of Perl". Chicago Tribune. Archived from the original on April 30, 2011. Retrieved January 10, 2011.
- ^ Kalita, Jugal (December 2003). On Perl: Perl for Students and Professionals. Universal-Publishers. ISBN 978-1-58112-550-4.
- "Perl Culture". docstore.mik.ua. Retrieved March 16, 2023.
- Holloway, Ruth. "Perl turns 30 and its community continues to thrive". Opensource.com. Retrieved June 23, 2023.
- "Programming Perl, 3rd Edition [Book]". www.oreilly.com. Retrieved April 11, 2023.
- "perlhist - the Perl history records - Perldoc Browser". perldoc.perl.org. Retrieved July 28, 2023.
- "perl.perl5.porters archive". perl.org. Archived from the original on May 1, 2011. Retrieved January 13, 2011.
- ^ "perlhist: the Perl history records". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on January 13, 2011. Retrieved January 21, 2011.
- "Perl: Definition, History, & Facts". Britannica.com. Retrieved June 15, 2022.
- "CPAN". CPAN. Archived from the original on October 3, 2019. Retrieved December 19, 2022.
- ^ "perl5004delta – what's new for perl5.004". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on February 27, 2011. Retrieved January 8, 2011.
- Patwardhan, Nathan; Siever, Ellen; Spainhour, Stephen (2002). Perl in a Nutshell, Second Edition. O'Reilly Media. ISBN 978-0-596-00241-1.
- "perl5005delta - what's new for perl5.005". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on February 3, 2011. Retrieved January 21, 2011.
- "Perl Source". cpan.org. Retrieved November 26, 2023.
- "perl56delta - what's new for perl v5.6.0". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on February 2, 2011. Retrieved January 21, 2011.
- "perl56delta - what's new for perl v5.6.x". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on November 18, 2010. Retrieved January 21, 2011.
- "Perl | Definition, History, & Facts | Britannica". www.britannica.com. Retrieved June 15, 2022.
- Wall, Larry. "Apocalypse 1: The Ugly, the Bad, and the Good". Archived from the original on November 23, 2010. Retrieved January 8, 2011.
- "perl58delta - what is new for perl v5.8.0". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on November 21, 2010. Retrieved January 21, 2011.
- "A Plan for Pugs". O'Reilly Media. March 3, 2005. Archived from the original on September 8, 2012. Retrieved January 27, 2011.
- Tang, Audrey (April 21, 2010). "Re: How to Implement Perl 6 in Ten Years". PerlMonks. Archived from the original on May 11, 2011. Retrieved January 3, 2011.
- Broadwell, Geoff (August 8, 2005), OSCON 4.4: Inside Ponie, the Bridge from Perl 5 to Perl 6, O'Reilly ONLamp Blog, archived from the original on March 14, 2012, retrieved June 27, 2016
- Vincent, Jesse (August 23, 2006), Ponie has been put out to pasture, The Perl Foundation, archived from the original on June 27, 2009, retrieved January 15, 2019
- "perl5100delta - what is new for perl 5.10.0". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on December 21, 2010. Retrieved January 8, 2011.
- "perlsyn - Perl syntax". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on August 26, 2013. Retrieved January 21, 2011.
- "perl5120delta - what is new for perl v5.12.0". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on January 4, 2011. Retrieved January 8, 2011.
- "perl5140delta - what is new for perl v5.14.0 - metacpan.org". metacpan.org. Archived from the original on July 25, 2018. Retrieved July 22, 2017.
- ^ "perl5160delta - what is new for perl v5.16.0". perldoc.perl.org. Retrieved May 21, 2012.
- "perl5180delta - what is new for perl v5.18.0 - Perl programming language". Perl 5 version 18.0 documentation. metacpan.org. Archived from the original on October 29, 2013. Retrieved October 27, 2013.
- "perl5200delta - what is new for perl v5.20.0 - Perl programming language". Perl 5 version 20.0 documentation. metacpan.org. Archived from the original on May 27, 2014. Retrieved May 27, 2014.
- Milestones in the Perl Renaissance – Modern Perl Programming Archived October 27, 2012, at the Wayback Machine. Modernperlbooks.com. Retrieved on 2013-07-17.
- Preface (Modern Perl 2011-2012) Archived September 28, 2012, at the Wayback Machine. Modernperlbooks.com. Retrieved on 2013-07-17.
- Modern Perl 2011-2012 edition by chromatic |Onyx Neon Press Archived December 22, 2011, at the Wayback Machine. Onyxneon.com. Retrieved on 2013-07-17.
- "Enlightened Perl". Enlightened Perl. Archived from the original on February 5, 2014. Retrieved September 28, 2012.
- "YAPC::NA 2013 – June 3–5, Austin, Texas". Yapcna.org. June 4, 2013. Archived from the original on June 22, 2013. Retrieved April 11, 2014.
- Little, Stevan (February 8, 2013). "What is Moe (a clarification) | Stevan Little". Blogs.perl.org. Archived from the original on December 19, 2013. Retrieved April 11, 2014.
- "p2 on potion". Perl11.org. February 7, 2004. Archived from the original on September 24, 2013. Retrieved April 11, 2014.
- "goccy/gperl 路 GitHub". GitHub.com. Archived from the original on February 23, 2015. Retrieved April 11, 2014.
- "rperl". RPerl.org. Archived from the original on October 18, 2014. Retrieved August 11, 2014.
- "Perl 6". The Perl 6 Project. Archived from the original on February 21, 2011. Retrieved February 27, 2011.
- Torkington, Nathan. "Transcription of Larry's talk". nntp.perl.org. Archived from the original on May 1, 2011. Retrieved January 25, 2011.
- "Perl6 - The future of Perl". www.java-samples.com. Retrieved May 18, 2021.
- "Official Perl 6 Documentation". The Perl 6 Project. Archived from the original on August 31, 2009. Retrieved January 25, 2011.
- Kuhn, Bradley M. (January 2001). Considerations on Porting Perl to the Java Virtual Machine (MS thesis). University of Cincinnati. Archived from the original on March 21, 2008. Retrieved June 28, 2008.
- chromatic (2015). Modern Perl. Pragmatic Bookshelf. ISBN 978-1-68050-088-2.
- "Feature comparison of Perl 6 compilers". Archived from the original on August 11, 2017. Retrieved March 28, 2012.
- Worthington, Jonathan (July 15, 2013). "Rakudo JVM News: More tests, plus Thread and Promise prototypes". 6guts. Archived from the original on October 5, 2013. Retrieved July 24, 2013.
- Worthington, Jonathan (May 31, 2013). "MoarVM: A virtual machine for NQP and Rakudo". 6guts. Archived from the original on July 9, 2013. Retrieved July 24, 2013.
- "rename-lwn". Archived from the original on October 17, 2019. Retrieved November 10, 2019.
- "rakudo/rakudo - GitHub". GitHub.com. Archived from the original on July 29, 2017. Retrieved September 21, 2013.
- ^ "Perl 7 announced at Perl Conference in the Cloud". perlfoundation.org. June 24, 2020. Archived from the original on June 26, 2020. Retrieved June 24, 2020.
- ^ "Announcing Perl 7". perl.com. June 24, 2020. Archived from the original on June 24, 2020. Retrieved June 24, 2020.
- Clark, Nicholas (May 9, 2021). "Steering Council meeting #019 2021-05-06". www.nntp.perl.org. Archived from the original on May 18, 2021. Retrieved May 17, 2021.
The plan remains that there will be a Perl 7 bump, but not immediately after 5.34.0 is released. ... We don't think that we can deliver on in 12 months.
- Preparing for Perl 7d. leanpub.com. June 24, 2020. Archived from the original on June 25, 2020. Retrieved June 24, 2020.
- Perl Steering Council. "What happened to Perl 7?". blogs.perl.org. Retrieved July 7, 2022.
- Richardson, Marjorie. "Larry Wall, the Guru of Perl | Linux Journal". www.linuxjournal.com. Linux Journal. Retrieved January 16, 2023.
- Schwartz, Alan (December 1998). "Tutorial: Perl, a psychologically efficient reformatting language". Behavior Research Methods, Instruments, & Computers. 30 (4): 605–609. doi:10.3758/BF03209477. ISSN 0743-3808. S2CID 61028367.
- Gilbert, James G. R. (March 2002). "How to become a programming tadpole". Nature Biotechnology. 20 (3): 221. doi:10.1038/nbt0302-221. ISSN 1087-0156. S2CID 38728402.
- "The Fall Of Perl, The Web's Most Promising Language". FastCompany. February 13, 2014.
- Wall, Larry. "perl - The Perl 5 language interpreter - Perldoc Browser". perldoc.perl.org. Retrieved June 24, 2021.
- Wall, Larry (March 1, 1997). "Wherefore Art, Thou?". Linux Journal. Archived from the original on December 9, 2010. Retrieved March 13, 2011.
- "perlfunc - Perl builtin functions". Perl 5 version 12.2 documentation. perldoc.perl.org. Archived from the original on January 6, 2011. Retrieved January 10, 2011.
- Nagpal, D.P. (2010). Web Design Technology. India: S. Chand. p. 700. ISBN 978-8121927635.
- "title unknown". May 10, 1997. Usenet: 199705101952.MAA00756@wall.org.
- "Developer Update". Dr. Dobb's Developer Update. 2. Miller-Freeman. 1995.
- ^ Schwartz, Randal L. (1993). Learning Perl. O'Reilly & Associates. Bibcode:1993lepe.book.....S.
- "perlintro". Perl 5 version 18.0 documentation. Perl 5 Porters and perldoc.perl.org. Archived from the original on January 9, 2011. Retrieved June 30, 2013.
- "perlstyle". Perl 5 version 18.0 documentation. Perl 5 Porters and perldoc.perl.org. Archived from the original on June 26, 2013. Retrieved June 30, 2013.
- ^ "Perl 6 FAQ". Perl 6 Project. Archived from the original on July 1, 2013. Retrieved June 30, 2013.
- ^ chromatic (December 31, 2012). "The Implementation of Perl 5 versus Perl 6". Archived from the original on July 29, 2013. Retrieved June 30, 2013.
- "Perl 6 Specification". The Perl 6 Project. Archived from the original on December 2, 2009. Retrieved January 27, 2011.
- "Perl 6 Compilers". The Perl 6 Project. Archived from the original on December 2, 2009. Retrieved January 27, 2011.
- A description of the Perl 5 interpreter can be found in Programming Perl, 3rd Ed., chapter 18. See particularly page 467, which carefully distinguishes run phase and compile phase from run time and compile time. Perl "time" and "phase" are often confused.
- "perlguts - Introduction to the Perl API - Perldoc Browser". perldoc.perl.org. Retrieved January 24, 2022.
- Schwartz, Randal. "On Parsing Perl". Archived from the original on September 27, 2007. Retrieved January 3, 2007.
- "The Perl Journal #19/9.26" (PDF). O'Reilly Media. Retrieved February 4, 2011.
- Kegler, Jeffrey (October 7, 2011). "Perl and Parsing 11: Are all Perl programs parseable?". Retrieved October 25, 2022.
... we seem to be giving up absolutely nothing. Nobody has ever been able to show a practical downside
- Kennedy, Adam (2006). "PPI—Parse, Analyze and Manipulate Perl (without perl)". CPAN. Archived from the original on September 3, 2013. Retrieved September 16, 2013.
- "Rice's Theorem". The Perl Review. 4 (3): 23–29. Summer 2008. and "Perl is Undecidable". The Perl Review. 5: 7–11. Fall 2008., available online at Kegler, Jeffrey. "Perl and Undecidability". Archived from the original on August 17, 2009. Retrieved January 4, 2009.
- Hietaniemi, Jarkko (1998). "Perl Ports (Binary Distributions)". CPAN.org. Archived from the original on April 18, 2006. Retrieved April 16, 2006.
- "The MacPerl Pages". Prime Time Freeware. 1997. Archived from the original on January 18, 2006. Retrieved January 18, 2006.
- "Perl Ports (Binary Distributions)". CPAN. Archived from the original on April 18, 2006. Retrieved January 27, 2011.
- "ActivePerl is Perl for Windows, Mac, Linux, AIX, HP-UX & Solaris". ActiveState Software. Archived from the original on March 31, 2016. Retrieved January 9, 2011.
- "Using PPM". ActiveState Software. Archived from the original on August 27, 2010. Retrieved January 9, 2011.
- Crane, Dana (July 23, 2019). "Goodbye PPM, Hello State Tool". Activestate.com. Archived from the original on July 28, 2020. Retrieved April 16, 2020.
- readme.txt
- "Alioth: The Computer Language Benchmarks Game: Project Info". Alioth. Archived from the original on March 25, 2013. Retrieved January 13, 2011.
- "Which programs are fastest?". Computer Language Benchmarks Game. Alioth. Archived from the original on May 17, 2013. Retrieved January 13, 2011.
- Leroy, Jean-Louis (December 1, 2005). "A Timely Start". O'Reilly. Archived from the original on June 13, 2006. Retrieved May 22, 2006.
- Beattie, Malcolm & Enache Adrian (2003). "B::Bytecode Perl compiler's bytecode backend". CPAN. Archived from the original on March 30, 2021. Retrieved September 16, 2013.
- Schwartz, Randal; foy, brian; Phoenix, Tom (June 23, 2011). Learning Perl. "O'Reilly Media, Inc.". ISBN 978-1-4493-0358-7.
- Stein, Lincoln; MacEachern, Doug (1999). Writing Apache Modules with Perl and C: The Apache API and Mod_perl. "O'Reilly Media, Inc.". ISBN 978-1-56592-567-0.
- Bekman, Stas; Cholet, Eric (2003). Practical Mod_perl. "O'Reilly Media, Inc.". ISBN 978-0-596-00227-5.
- Ingerson, Brian. "Inline - metacpan.org". CPAN. Archived from the original on June 13, 2013. Retrieved January 26, 2011.
- Gilmore, W. J. (2010). Beginning PHP and MySQL: From Novice to Professional, Fourth Edition. Apress. p. 484. ISBN 978-1-4302-3114-1.
- "IMDb Helpdesk: What software/hardware are you using to run the site?". Internet Movie Database. Archived from the original on March 9, 2017. Retrieved February 12, 2011.
- DuckDuckGo handles a large amount of search queries at 4.5 million queries per day . https://duckduckgo.com/traffic.html Archived February 15, 2012, at the Library of Congress Web Archives
- DuckDuckGo uses Perl https://web.archive.org/web/20101231135106/http://www.gabrielweinberg.com/blog/2009/03/duck-duck-go-architecture.html
- "Perl FAQ". Archived from the original on August 6, 2019. Retrieved August 6, 2019.
Perl is used quite extensively in Debian. Not only are some core functions written in Perl, but there are over 700 packages in unstable that have perl in their name (Mar 2004).
- "Perl Books - Book: Data Munging with Perl". Perl.org. Archived from the original on September 7, 2011. Retrieved December 30, 2010.
- Descartes, Alligator; Bunce, Tim (2000). Programming the Perl DBI : [database programming with Perl] (1 ed.). Beijing : O'Reilly. ISBN 978-1-56592-699-8.
- "Perl Programming - Principles of Programming Languages". sites.google.com. Archived from the original on October 8, 2020. Retrieved May 18, 2021.
- Bunce, Tim; Descartes, Alligator (February 4, 2000). Programming the Perl DBI: Database programming with Perl. "O'Reilly Media, Inc.". ISBN 978-1-4493-1536-8.
- Bekman, Stas. "Efficient Work with Databases under mod_perl". Archived from the original on August 22, 2007. Retrieved September 1, 2007.
- Pachev, Sasha (April 10, 2007). Understanding MySQL Internals: Discovering and Improving a Great Database. "O'Reilly Media, Inc.". ISBN 978-0-596-55280-0.
- "Class::DBI - Simple Database Abstraction - metacpan.org". metacpan.org. Archived from the original on August 6, 2020. Retrieved April 8, 2020.
- "Rose::DB::Object - Extensible, high performance object-relational mapper (ORM). - metacpan.org". metacpan.org. Archived from the original on August 6, 2020. Retrieved April 8, 2020.
- "T sql querying developer reference". pdfpremiumfree.com. Retrieved May 18, 2021.
- Wall, Larry (May 22, 2014). "Perl Culture (AKA the first State of the Onion)". Archived from the original on May 22, 2014. Retrieved May 22, 2014.
- Wall, Larry. "2nd State of the Onion". Archived from the original on July 17, 2012. Retrieved October 12, 2012. (Search for 'church')
- Schwartz, Randal L. (May 2, 1999). "Who is Just another Perl hacker?". Newsgroup: comp.lang.perl.misc. Usenet: m1hfpvh2jq.fsf@halfdome.holdit.com. Archived from the original on July 8, 2012. Retrieved December 5, 2014.
- Schwartz, Randal (March 31, 2005). "Canonical JAPH". PerlMonks. Archived from the original on July 22, 2011. Retrieved May 16, 2011.
- Bacon, Greg (May 28, 1999). "Re: Incrementing a value in a slice". Newsgroup: comp.lang.perl.misc. Usenet: 7imnti$mjh$1@info2.uah.edu. Archived from the original on July 7, 2011. Retrieved July 12, 2011.
- Back, Adam. "RSA in 5 lines of perl". Archived from the original on January 19, 2011. Retrieved January 10, 2011.
- "Code Golf: What is Code Golf?". 29degrees. 2007. Archived from the original on January 13, 2012. Retrieved November 26, 2018.
- Gallo, Felix (2003). "The Zeroth Obfuscated Perl Contest" (PDF). In Jon Orwant (ed.). Games, diversions, and Perl culture: best of the Perl journal. O'Reilly Media. Archived from the original (PDF) on November 22, 2009. Retrieved January 12, 2011.
- "Perl Poetry". PerlMonks. Archived from the original on September 27, 2007. Retrieved January 27, 2011.
Further reading
- Learning Perl 6th Edition (2011), O'Reilly. Beginner-level introduction to Perl.
- Beginning Perl 1st Edition (2012), Wrox. A beginner's tutorial for those new to programming or just new to Perl.
- Modern Perl Archived December 22, 2011, at the Wayback Machine 2nd Edition (2012), Onyx Neon. Describes Modern Perl programming techniques.
- Programming Perl 4th Edition (2012), O'Reilly. The definitive Perl reference.
- Effective Perl Programming 2nd Edition (2010), Addison-Wesley. Intermediate- to advanced-level guide to writing idiomatic Perl.
- Perl Cookbook, ISBN 0-596-00313-7. Practical Perl programming examples.
- Dominus, Mark Jason (2005). Higher Order Perl. Morgan Kaufmann. ISBN 978-1-55860-701-9. Functional programming techniques in Perl.
External links
Perl | |
---|---|
Things | |
Frameworks | |
Software | |
Related | |
Books | |
People | |
Programming languages | |
---|---|
Free and open-source software | |||
---|---|---|---|
General | |||
Software packages | |||
Community | |||
Organisations | |||
Licenses |
| ||
Challenges | |||
Related topics | |||
- Perl
- American inventions
- Programming languages
- C programming language family
- Cross-platform software
- Dynamic programming languages
- Dynamically typed programming languages
- Free and open source interpreters
- Free software programmed in C
- High-level programming languages
- Multi-paradigm programming languages
- Object-oriented programming languages
- Procedural programming languages
- Programming languages created in 1987
- Scripting languages
- Software using the Artistic license
- Text-oriented programming languages
- Unix programming tools